Datasheet

19
Chapter 1: The Least You Need to Know about HTML, CSS, and the Web
Tag pairs
Elements that describe content use a tag pair to mark the beginning and the
end of the element. Start and end tag pairs look like this:
<tag>...</tag>
Content — such as paragraphs, headings, tables, and lists — always uses a tag
pair:
The start tag (<tag>) tells the browser, “The element begins here.”
The end tag (</tag>) tells the browser, “The element ends here.”
Actual content is what occurs between a start tag and an end tag. For exam-
ple, the Ed Tittel page in Listing 1-1 uses a paragraph element (<p>) to sur-
round text for a paragraph (we omit CSS inline markup for clarity):
<p>
Ed started writing about computing subjects in 1986 for a
Macintosh oriented monthly magazine. By 1989 he had contributed to such
publications as LAN Times, Network World, Mac World, and LAN Magazine. He worked
on his first book in 1991, and by 1994 had contributed to over a dozen different
titles.
</p>
Single tags
Elements that insert something into the page are called empty elements
(because they enclose no content) and use just a single tag, like this:
<tag />
Images and line breaks insert something into the HTML file, so they use
one tag.
One key difference between XHTML and HTML is that, in XHTML, all empty
elements must end with a slash before the closing greater-than symbol. This
is because XHTML is based on XML, and the XML rule is that you close empty
elements with a slash, like this:
<tag/>
However, to make this kind of markup readable inside older browsers, you
should insert a space before the closing slash, like this:
<tag />
06_9780470916599-ch01.indd 1906_9780470916599-ch01.indd 19 11/30/10 12:23 AM11/30/10 12:23 AM