Jump to content

organize your code?


thetylercox

Recommended Posts

So more of an aesthetics question. Where do you put what when coding or what is the preferred order?

example!

style

html

head

script

php

head

body

 

Speaking in the case of order does not matter! Yes I get that it does just curious how some of you organize your code.

 

 

Link to comment
Share on other sites

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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.