Help - Search - Members - Calendar
Full Version: Containerisation
HTMLHelp Forums > Web Authoring > Cascading Style Sheets
James
In my CSS studies I have learned about putting containers within containers, but one thing is not clear to me and that is: should the entire page you are looking at be in a container, or do we assume that <body> is that parent container.

For example, if you wanted to have a banner header, a navigation bar, and a contents wrapper, would you have this:

<div id="header">
</div>
<div id="navbar">
</div>
<div id="contents>
</div>

or, would you have this:

<div id="page">
<div id="header">
</div>
<div id="navbar">
</div>
<div id="contents>
</div>
</div>

Thanks, James
pandy
QUOTE
should the entire page you are looking at be in a container


Only if you need it for something. Rule of thumb - less is more, but don't be afraid to use an extra DIV if it helps you with your CSS. IMO that's better than resorting to evil CSS hacks.

What you should avoid is to use DIV and SPAN instead of more meaningful elements, like headings a nd paragraphs.

An example. Say you have a list, for navigation maybe. You want the whole list to have a common background, borders, whatever. There's no point in doing...

CODE
<div id="nav">
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
</div>


...because you can just as well apply the CSS to UL directly. It already acts as a container for all the list items.

CODE

<ul id="nav">
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
pandy
BTW I like that word, "containerisation". biggrin.gif
James
QUOTE(pandy @ Jul 13 2008, 07:58 AM) *

BTW I like that word, "containerisation". biggrin.gif


Thanks for your good advice, Pandy.

Regards, James
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.