Jump to content

organize your code?


thetylercox

Recommended Posts

The most aesthetically pleasing thing is to keep all your scripting out of your html.

 

You could do something like this:

 

<script language="php">include('my_fantastic_script.php');</script>
<html>
<head>
<title><?=$title?></title>
<link rel="stylesheet" href="<?=$stylesheet?>" type="text/css" />
<script type="text/javascript" src="<?=$javascript?>"></script>
</head>
<body>
<div id="wrapper">
	<div id="left_col">
		<h1><?=$h1_title?></h1>
		<?=$content?>
	</div>
	<div id="right_col">
		<?=col_content?>
	</div>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353657
Share on other sites

Even when you do a plain <style> section rather than a separate file, doesn't it have to go within the HTML, not before your opening html tag?

 

nothing should be before your html tag, except your doctype

 

doctage
<html>
<head>
...
</head>
<body>
...
</body>
</html>

 

& some reading material: http://www.w3.org/TR/1999/REC-html401-19991224/struct/tables.html#adef-scope

Link to comment
https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1353957
Share on other sites

nothing should be before your html tag, except your doctype

 

That should really be phrased as no style sheets, javascript or HTML should be before your HTML tag. PHP is frequently, and most usually SHOULD be before any HTML.

 

 

CSS, and Javascript (unless its absolutely necessary to place it somewhere else), should be inside the head tag.

 

And it is of course better to get all CSS, and as much Javascript and PHP as possible out of the actual documents that contain HTML.

 

Where PHP is necessary in HTML is to format the display with conditionals.

Link to comment
https://forums.phpfreaks.com/topic/264141-organize-your-code/#findComment-1354045
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.