Lecture 3: Block-Level Elements, Part I

Overview:

  1. Block-Level Elements
  2. Headings
  3. Paragraphs
  4. Divisions
  5. Line Breaks

Block-Level Elements

Headings

Attribute Usage and Effect Values Accepted Default Deprecated?
align Horizontally aligns the text within the heading. left | center | right | justify left Deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Headings in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>This is a Level 1 Heading</h1>

    <h2 align="center">This is a centered Level 2 Heading</h2>

    <h3 align="right">This is a right-aligned Level 3 Heading</h3>

    <h4 align="justify">This is a Level 4 Heading</h4>

    <h5>This is a Level 5 Heading</h5>

    <h6>This is a Level 6 Heading</h6>
</body>
</html>

See how this example renders

Paragraphs

Attribute Usage and Effect Values Accepted Default Deprecated?
align Horizontally aligns the text within the paragraph. left | center | right | justify left Deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Headings and Paragraphs in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>This is a Level 1 Heading</h1>

    <p>This is a paragraph.</p>

    <h2 align="center">This is a centered Level 2 Heading</h2>

    <p>This is another paragraph.</p>

    <h3 align="right">This is a right-aligned Level 3 Heading</h3>

    <p align="center">This paragraph is centered.</p>

    <h4 align="justify">This is a Level 4 Heading</h4>

    <h5>This is a Level 5 Heading</h5>

    <h6>This is a Level 6 Heading</h6>
</body>
</html>

See how this example renders

Divisions

Attribute Usage and Effect Values Accepted Default Deprecated?
align Horizontally aligns the text within the division. left | center | right | justify left Deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Headings, Paragraphs, and Divisions in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>This is a Level 1 Heading</h1>

    <p>This is a paragraph.</p>

    <h2 align="center">This is a centered Level 2 Heading</h2>

    <p>This is another paragraph.</p>

    <h3 align="right">This is a right-aligned Level 3 Heading</h3>

    <p align="center">This paragraph is centered.</p>

    <h4 align="justify">This is a Level 4 Heading</h4>

    <h5>This is a Level 5 Heading</h5>

    <h6>This is a Level 6 Heading</h6>

    <div>This text is in a division.  The space above this text is from
    the bottom margin of the &lt;h6&gt; tag.</div>

    <div align="right">This text is in another division.
    There is no space between this text and the line above, because divisions
    have no default margins above and below.</div>
</body>
</html>

See how this example renders

Line Breaks

Attribute Usage and Effect Values Accepted Default Deprecated?
clear Forces content following the line break to wait until there is nothing on the indicated side(s) before rendering. Often used with images so that text will not wrap around the graphic; this would force the text to appear below the image. left | all | right | none none Deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Headings, Paragraphs, Divisions, and Line Breaks in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <h1>This is a Level 1 Heading</h1>

    <p>This is a paragraph.</p>

    <h2 align="center">This is a centered Level 2 Heading</h2>

    <p>This is another paragraph.<br />
    A line break moved this text to a new line.</p>

    <h3 align="right">This is a right-aligned Level 3 Heading</h3>

    <p align="center">This paragraph is centered and has a <br />
    line break.</p>

    <h4 align="justify">This is a Level 4 Heading</h4>

    <h5>This is a Level 5 Heading</h5>

    <h6>This is a Level 6 Heading</h6>

    <div>This text is in a division.  The space above this text is from
    the bottom margin of the &lt;h6&gt; tag.</div>

    <div align="right">This text is in another division.
    There is no space between this text and the line above, because divisions
    have no default margins above and below.</div>
</body>
</html>

See how this example renders