Division tags rarely stand alone. Contemporary HTML documents employ a series of divs that represent major areas of the page or template. Generally, a well-designed but simple webpage will have between four to seven division tags and more complex sites employ dozens in a single page.
The method used to create multiple box models (division tag designs) is using a CSS ID. This, like a CSS class, allows the identification of an individual tag that can be assigned unique attributes. Here are some common div IDs:
These names are not mandated by the W3C (the governing board of Web standards), these are simply commonly used ID names. You can create your own reference names that do not replicate XHTML tags or have spaces. Another important rule about IDs is that an individual ID may only be referred to once per page.
The following is the method for introducing an ID in CSS:
#header {
width: 770px;
height: 70px;
background-color: #666;
border: 1px #ff0 solid;
}
And, like a CSS class, we refer to the ID as an attribute in the HTML tag:
<div id=“header">
<img src=“sitelogo.png" />
</div>
For today, we will make three divs: a header (like above), a content div and a footer. These three elements will stack atop each other and appear to be part of a uniform design, assuming our three divs are composed following these simple rules:
Starting at the body tag in this example, the CSS ID is indicated as an attribute within the applicable tag. We primarily use this for DIV elements. Use the HTML template, if desired.
<body>
<div id="header">
<img src="logo.gif" />
</div>
<div id="content">
<h1>My DIV page</h1>
<p>Insert lorem ipsum or story content here</p>
<p>More paragraph stuff here</p>
</div>
<div id="footer">
© 2011 John Doe
</div>
</body>
</html>
IDs are indicated in CSS with a hashmark, followed by a single-word ID name that references its function. For example:
#header {
width: 900px;
border: #ccc solid 1px;
margin: 5px;
padding: 20px;
background-color: #eee;
}#content {
width: 900px;
border: #ccc solid 1px;
margin: 5px;
padding: 20px;
background-color: #eee;
}#footer {
width: 900px;
border: #ccc solid 1px;
margin: 5px;
padding: 20px;
background-color: #eee;
}
You will notice a "©" in the footer. This, as you likely surmised, is the HTML character code for the copyright sign (©). There is a list of these linked from week four of the online schedule.
Matthew Blake Department of Journalism CSU-Chico
mdblake@csuchico.edu (530) 898-3608