Section 2.3. Embedded Tags


2.3. Embedded Tags

You probably noticed right away, perhaps in surprise, that the browser displays less than half of the example source text. Closer inspection of the source reveals that what's missing is everything that's bracketed inside a pair of less-than ( < ) and greater-than ( > ) characters . [The Syntax of a Tag, 3.3.1]

HTML and XHTML are embedded languages: you insert their directions, or tags , into the same document that you and your readers load into a browser to view. The browser uses the information inside those tags to decide how to display or otherwise treat the subsequent contents of your document.

For instance, the <i> tag that follows the word Hello in the simple example tells the browser to display the following text in italics. [*] [Physical Style Tags, 4.5]

[*] Italicized text is a very simple example and one that most browsers, except the text-only variety (e.g., Lynx), can handle. In general, the browser tries to do as it is told, but as we demonstrate in upcoming chapters, browsers vary from computer to computer and from user to user, as do the fonts that are available and selected by the user for viewing HTML documents. Assume that not all are capable of or willing to display your HTML document exactly as it appears on your screen.

The first word in a tag is its formal name , which usually is fairly descriptive of its function, too. Any additional words in a tag are special attributes , sometimes with an associated value after an equals sign ( = ), which further define or modify the tag's actions.

2.3.1. Start and End Tags

Most tags define and affect a discrete region of your document. The region begins where the tag and its attributes first appear in the source document (a.k.a. the start tag ) and continues until a corresponding end tag . An end tag is the tag's name preceded by a forward slash ( / ). For example, the end tag that matches the "start italicizing" <i> tag is </i> .

End tags never include attributes. In HTML, most tags, but not all, have an end tag. And, to make life a bit easier for HTML authors, the browser software often infers an end tag from surrounding and obvious context, so you needn't explicitly include some end tags in your source HTML document. (We tell you which are optional and which are never omitted when we describe each tag in later chapters.) Our simple example is missing an end tag that is so commonly inferred and hence not included in the source that some veteran HTML authors don't even know that it exists. Which one?

The XHTML standard is much more rigid, insisting that all tags have corresponding end tags. [End Tags, 16.3.2] [Handling Empty Elements, 16.3.3]



HTML & XHTML(c) The definitive guide
Data Networks: Routing, Security, and Performance Optimization
ISBN: 596527322
EAN: 2147483647
Year: 2004
Pages: 189
Authors: Tony Kenyon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net