A typical page structure
- Header (or masthead) at the top of the page, usually containing the top level heading of the page, and/or a company logo. This is the big bold statement at the top of the page that says what the web site is, and who it belongs to.
- Main content column, which holds the main content of functionality you are here to use.
- One of more sidebars, holding tributary content that is either related to that page's main content and changes as new pages are loaded (eg related links), or is always relevant and persists across the whole site (eg "your basket" information on an e-commerce site).
- Navigation menu going across the page or down the page in a column. This often put in a sidebar, or may form part of the header.
- A footer that goes across the bottom of the site and contains secondary information such as copyright information and contact details.
Lets visualise this a bit more with a specific example. The web site of Conquest of Steel (Chris Mills' band!) looks like so
Figure 1: A typical example web site.
We could break this up into the sections we have just discussed, like so:
Figure 2: the example site, with distinct sections overlaid.
These sections could contain any number of different nested elements, for example a footer could include a list full of links, a couple of paragraphs and an image. But how do we mark up these distinct sections, and group them together as single entities that can be laid out later on using CSS? Lets have a look, in the next section.
Structuring a page with HTML 4
HTML4 contains two generic container elements:
- The
<div>is a block level container that you can use to group sections of block level content together. - The
<span>is an inline container that you can use to group sections of inline content together.
Note that
<div> and <span> elements have no inherent content or dimensions, only that of their contents, until they are styled via CSS or manipulated by JavaScript. They also have no semantics, and the only way you can identify them is by giving them a class or id attribute.
You should only use these elements when there isn't a more appropriate, semantic element to use for marking up content. Marking up paragraphs and headings all with
<div>s is a terrible thing to do, as although it might look ok, the page will be inaccessible to those using screen readers (screen readers need a good structure of headings to navigate by), plus it will be more bloated, harder to read, and less efficient to style with CSS. Try to cut down on the number of <div>s and <span>s used when possible: an abuse of these elements leads to what we call "divitis".
So, to mark up the example site, you could use the following elements:
Figure 3: The example site, with appropriate HTML4 elements indicated for different major structural sections.
The markup would look something like this:
<body>
<div id="header">
<!-- header content goes in here -->
</div>
<div id="nav">
<!-- navigation menu goes in here -->
</div>
<div id="sidebar1">
<!-- sidebar content goes in here -->
</div>
<div id="main">
<!-- main page content goes in here -->
</div>
<div id="sidebar2">
<!-- sidebar content goes in here -->
</div>
<div id="footer">
<!-- footer content goes in here -->
</div>
</body>
![]() |
| Nesting dolls is a good way to look at web building |




No comments:
Post a Comment