Divs and spans

Divs and spans are two tags that, when used well, can help give your page a logical structure
and some extra hooks to apply any CSS or DOM scripting that you might need later. When
used badly, they can litter your document unnecessarily and make your markup, styling, and
scripting needlessly complicated.


<div id="header">
...
</div>
<div id="mainContent">
...
</div>
<div id="secondaryContent">
...
</div>
<div id="footer">
...
</div>

A span is used for marking out sections within a block element and sometimes inside
another inline element. It is an inline element, just the same as <em>, <strong>, or <a>,
except without any semantic meaning—it is simply a generic container. It can itself contain
further inline elements, including more spans. For example, say you wish to color the first
two words of a paragraph red, keeping the rest of the paragraph black. You can use a
<span> for this:
<p><span class="leadingWords">The first</span> two words of this å
paragraph can now be styled differently.</p>
A span cannot contain a block element—that is, you cannot place a <div> within a <span>
and expect it to work the way you want.