The <div> tag defines a division or section in a page and makes it easy to manage, style, and manipulate those divisions or sections. Browsers usually place a line break before and after the div element. Use the <div> tag to group block-elements to format them with styles. Some examples would be the basic layout of this page.
In HTML 4.01 documents, the <div> tag was often used for specifying the various navigational sections of the HTML document (such as the header, footer, content area, side bars, etc).
The HTML 5 specification has introduced a number of new elements that can (and should) be used instead of the <div> element. Examples of these new elements include <article>, <aside>, <header>, and <footer>, as well as others.
This site uses <div> tags for the page layout. Each is styled by using an id and applying the style rules. Remember an id is used only once on a page. Examples of style id's and how they are used:
Of course <div> tags can be used for other things like the box below which does not have a width in the style rules so is contained only by the content <div>.
News
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus accumsan dolor ac orci? Pellentesque vitae libero in lacus tincidunt ultricies! Nam eleifend ultricies dui! Quisque mattis tempus ligula. Nulla non diam in arcu adipiscing porttitor. Nulla libero mi, suscipit id, semper eu, lobortis non, metus! Sed dui pede, consectetuer vitae, adipiscing et, posuere quis, nulla. Mauris ornare semper justo. Morbi at libero ut justo ultrices dignissim? Cras nunc. Sed metus quam, consequat vel, euismod et, pulvinar ut, sem. Vestibulum euismod massa posuere massa.
This <div> has a width added to the style which contains it to 50% of the allowable space.
News
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus accumsan dolor ac orci? Pellentesque vitae libero in lacus tincidunt ultricies! Nam eleifend ultricies dui! Quisque mattis tempus ligula. Nulla non diam in arcu adipiscing porttitor. Nulla libero mi, suscipit id, semper eu, lobortis non, metus! Sed dui pede, consectetuer vitae, adipiscing et, posuere quis, nulla. Mauris ornare semper justo. Morbi at libero ut justo ultrices dignissim? Cras nunc. Sed metus quam, consequat vel, euismod et, pulvinar ut, sem. Vestibulum euismod massa posuere massa.
You could add a different class with different style rules that would give a different look to the div on the same page.
My thanks to Jennifer McKemie who was the inspiration for this tutorial. Example of what you can do with a <div>. The example layout does not do well at 800x600 resolution because of the image included in the center <div>. I no longer design for anything lower than 800x600 BUT the page you are looking at will resize so that it does not fall apart at an even lower resolution. That is because the container uses a percentage width as does each <div> except the left navigation.
Copyright
2008 Pat Geary of
Expression Web Tips, Tutorials, and Templates All Rights Reserved
Expression Web 4.0 Tutorials 2nd Edition from Install to Publish, a FREE EBook by Pat Geary.
Expression Web has a group on Facebook. If you are a FB user, come join us.
Disclosure: This is an affiliate link, which means that if you visit Bluehost.com through this link and purchase this product, I’ll get a commission.
April 2007 - April 2013
Privacy Policy | Migrating from FrontPage to Expression Web
Microsoft® and Expression Web® are registered trademarks of Microsoft® Corporation.
Site Design & Maintenance : Expression Web Tutorials & Templates