HTML and CSS Reference
In-Depth Information
4.1. Divisions and Paragraphs
Like most text processors, a browser wraps the words it finds to fit the
horizontal width of its viewing window. Widen the browser's window, and
words automatically flow upward to fill the wider lines. Squeeze the win-
dow, and words wrap downward.
Unlike most text processors, however, HTML and XHTML use explicit di-
vision ( <div> ), paragraph ( <p> ), and line-break ( <br> ) tags to control
the alignment and flow of text. Return characters, although quite useful
for readability of the source document, typically are ignored by the
browserauthors must use the <br> tag to explicitly force a common text
line break. The <p> tag, while also causing a line break, carries with it
meaning and effects beyond a simple return.
The <div> tag is a little different. When originally codified in the HTML 3.2
standard, <div> was meant to be a simple organizational toolto divide the
document into discrete sections. That somewhat obtuse meaning meant
few authors used it. But recent innovations (alignment, styles, and the
id attribute for document referencing and automation) now let you more
distinctly label and thereby define individual sections of your documents,
as well as control the alignment and appearance of those sections. These
features breathe real life and meaning into the <div> tag.
By associating an id and a class name with the various sections of your
document, each delimited by a <div id=name class=name> tag and attrib-
utes (you can do the same with other tags, like <p> , too), you not only
label those divisions for later reference by a hyperlink and for automated
processing and management (collecting all the bibliography divisions, for
instance), but you may also define different, distinct display styles for
those portions of your document. For instance, you might define one di-
visional class for your document's abstract ( <div class=abstract> , for ex-
ample), another for the body, a third for the conclusion, and a fourth di-
visional class for the bibliography ( <div class=biblio> , for example).
Each class, then, might be given a different display definition in a
document-level or externally related stylesheet: for example, the ab-
Search WWH ::

Custom Search