DIV and SPAN are neutral HTML containers that have no default attributes, thus they are very useful for styling.

DIV

DIV tags can divide, or section, your document. They are block-level elements so browsers place a line break before and after them. DIVs are often used to position a portion of a page. DIV tags can be named which allows a developer to style certain sections of a document with CSS, or to perform other manipulations with DHTML.  EXAMPLE.

Tips for DIVs

<!-- Begin main content section --> <div id="main_content> code and content goes here </div> <!-- End main content section -->

SPAN

The SPAN tag has very similar properties to the DIV tag in that the text it encloses can be styled. However the SPAN tag is used to affect inline elements within the document. Items in a SPAN tag can be aligned or given specific style attributes.

Example:

This paragraph is just a normal paragraph which defaults to the 'normal' P style. This paragraph is just a normal paragraph which defaults to the 'normal' P style. However, this line in the paragraph is enclosed in a SPAN tag that is styled to be red. This paragraph is just a normal paragraph which defaults to the 'normal' P style.

CSS

span { color: rgb(255,0,0); }

HTML

<p>This paragraph is just a normal paragraph which defaults to the "normal" P style. This paragraph is just a normal paragraph which defaults to the "normal" P style. <span>However, this line in the paragraph is enclosed in a SPAN tag which is styled to be red.</span> This paragraph is just a normal paragraph which defaults to the "normal" P style. </p>

Figuring It Out

To look at existing styles and to help figure out how web pages are coded, use the Web Developer tools for Firefox (and other modern browsers). See the installation instructions for Firefox Open in a New Window and the Web Developer Toolbar Open in a New Window if you don't already have them installed. Later in this week's lecture I cover several very useful features of the Web Developer toolbar Open in a New Window that will help you to observe and explore web sites and see how they have constructed their designs. Combined with a web site's Source code and its CSS file, the Web Developer tools can help you deconstruct almost any page.

HINT: Start with simpler pages like this one and work your way up to complex pages like Ballade Open in a New Window!!