-
div and span elements are generic markup
to be used when no appropriate markup elements exist
- No additional default styling is provided by the browser for either element (unlike h1 and em, say)
-
div is a block level element that can contain block or inline elements
- Used to group elements together
- Each div area can be styled differently
- Good practice to use div elements to structure the page
- Frequently used for specifying styling for sections of a page
- Also used for interacting with a page via scripting
-
span is an inline element that can contain only inline elements
- Used for styling and interaction in the same way as div
<body>
<div id="head"><!--Header Info--></div>
<div id="main"><!--Main body of page--></div>
<div id="foot"><!--Footer Info-->
<p>Ring me on <span class="phone home">01275 345873</span> or
<span class="phone mobile">01345 345873</span>. Alternatively,
fax me on
<span class="fax work">01745 298524</span>. </p>
</div>
</body>