XHTML Basics - DIV or SPAN? DIV vs SPAN

These two tags are often used inter-changeably bycontrols using
developers fordifferent reasons, so what are theJavaScript.
differences between them? Howshould they be usedA SPAN tag is not intended to container other tags,
to markup web pages?but ratherto allow localised styling. This is especially
The basic difference between the two is theiruseful whencombined with classes. It has even been
default behaviour.suggested that futuresemantic web models will use
DIV tags are block-level tags and can be used assuch markup to define relevantcontent.
containers forother tags. SPAN tags are inline tagsFor example by defining a class telephone, when can
and should only containcontent. These defaultensure alltelephone numbers are displayed in the
behaviours can of course be altered bysame fashion:
CSS definitions, but are default in any browser44-20-555-4444
context.SPAN tags have similar properties but should be used
As a reference, if you want to align text within thesetoreference inline content and apply style by classes.
tags usethe following CSS attributes;In summary: use divs for defining sections of a page,
DIV - text-align: left|right|center|justifyand spansto enclose and style text or classes of
SPAN - float: left|righttext.
DIV tags are also used to define logical divisions ofPermission is granted for reproduction of this article,
pagecontent. It also allows CSS to be defined forso longas it is published in its entirety, with footnotes
whole sections ofattached.
HTML. By applying an id to a DIV you can also add