I was helping a few people with their HTML/CSS on another forum today and in almost every piece of code I looked at, there was the ubiquitous
<div id="container">
...
</div>
surrounding all other code. It’s almost as if it’s required HTML syntax like the <head> or <body> tags. I understand why people use it—to center or confine their fixed-width websites.
But what ever happened to the <body> or <html> tags? They’re containers just like anything else. Each of the below will achieve the same result (all other things remaining same)
#container {
margin:0 auto;
width:900px;
}
body {
margin:0 auto;
width:900px;
}
Using a system like ExpressionEngine with embeds and dynamically generated code etc… I can get really messy if there are open <div> tags (or any other tags). I generally feel the less markup used, the better (assuming the result is the same). So just wanted to post this tip for those that don’t know it or have ignored the poor <body> tag.
Maybe it’ll be of use to someone?
:D
