HTML Body: Block-level Elements
Certain HTML elements that may appear in
BODY are said to be "block-level" while
others are "inline" (also known as "text level").
Generally,
- inline elements may contain only data and other inline
elements. They do not create new lines.
- block-level elements may contain inline elements
and other block-level elements.
They begin on new lines,
and will close an unterminated paragraph element.
This enables you to omit end-tags for paragraphs in many cases.
Generally, block
elements create "larger" structures than inline elements.
By default, block-level elements are formatted differently than
inline elements.
|
The line just above was a header, i.e. a title for a new section of the
document.
A heading element briefly describes the topic of the section it
introduces.
Heading information may be used by user agents, for example,
to construct a table of contents for a document automatically.
There are 6 headers: H1, H2, H3, H4, H5, and H6.
H1 is the "main" header, usually used once at the top of the document.
H6 is the "smallest" header and is rarely used, though it's often
abused to make small bold text (use the FONT tag instead).
One of the original philosophies about HTML was that it should be
designed for software tools to extract useful information from HTML
documents. The header tags were supposed to be useful for generating a
'table of contents'.
Bear in mind that software other than visual browsers might visit your
web pages - e.g. text-to-speech convertors for the visually impaired,
or search engines. In such cases, good use of headings can give
valuable clues about the meaning of your page.
You always need the start and end tags.
H1 elements are more important than H2 elements and so on,
so that H6 elements define the least important level of headings.
More important headings are generally rendered in a larger font than
less important ones.
Use the ALIGN attribute to set the text alignment within a heading, e.g.
<H1 ALIGN=CENTER> <I>... centered heading ...</I> </H1>
ADDRESS
The ADDRESS element is used for information about the author of the document.
It requires start and end tags.
Block elements
-
P paragraphs
-
The paragraph element requires a start tag, but the end tag can always be
omitted.
-
PRE preformatted text
-
Requires start and end tags. These elements are rendered with a monospaced
font and preserve layout defined by whitespace and line break characters.
-
DIV document divisions
-
Requires start and end tags. It is used with the ALIGN attribute to set the
text alignment of the block elements it contains. ALIGN can be one of LEFT,
CENTER or RIGHT.
-
CENTER text alignment
-
Requires start and end tags. It is used to center text lines enclosed by
the CENTER element. See DIV for a more general solution.
-
BLOCKQUOTE quoted passage
-
Requires start and end tags. It is used to enclose extended quotations and
is typically rendered with indented margins.
-
FORM fill-out forms
-
Requires start and end tags. This element is used to define a fill-out form
for processing by HTTP servers. The attributes are ACTION, METHOD and ENCTYPE.
Form elements can't be nested.
-
ISINDEX primitive HTML forms
-
Not a container, so the end tag is forbidden. This predates FORM and is used
for simple kinds of forms which have a single text input field, implied by
this element.
-
HR horizontal rules
-
Not a container, so the end tag is forbidden. attributes are ALIGN, NOSHADE,
SIZE and WIDTH.
-
TABLE
can be nested
-
Requires start and end tags. Each table starts with an optional CAPTION followed
by one or more TR elements defining table rows. Each row has one or more
cells defined by TH or TD elements. attributes for TABLE elements are WIDTH,
BORDER, CELLSPACING and CELLPADDING.
|