Table of Contents
- Hello World!
- Understanding Tags and Structure
- Whitespace in XHTML
- Breakdown of a Tag
- Attributes
- Paragraphs and Line Breaks
- Validation and Browser Tools
Basic Structure
Breaking Down Tags
Lets take a more official, formal look at the tag.
Tag Components
Tags have three main components:
- tagname: Identifies the type of the tag.
- attribute: Allows one type of tag to produce different effects.
- value: Allows particular attributes to vary.
<tagname attribute1="value1"
attribute2="value2"...>
...(text or more tags go here)...
</tagname>
Attributes; Closing Tags
The closing of tags is a key difference between HTML and XHTML. See the XHTML section for details.
Not all tags require attributes to work properly. <html> and <head> almost never have attributes. However, all tags must close. For most tags this means they are accompanied by a closing tag, however, some tags self close. We will discuss these soon.
Attributes provide a lot of XHTML's flexibility and power, but for now, lets just talk about simple tags. We will discuss attributes in the next section.
Capitalization
The capitalization of tags is a key difference between HTML and XHTML. See the XHTML section for details.
All XHTML tags must be lowercase. Period, end of story. <BODY> is an invalid tag.
Misspellings and Misunderstandings
Vastly simplified, a browser processes an XHTML page something like this:
- Identify anything that is between angle brackets
(
< >) as a "tag" - Determine whether the browser has any instructions for using
the tag:
- If yes, the tag is real -- follow the instructions
- If no, the tag is garbage -- ignore it
When a browser ignores a tag, that means one of two things:
- The tag is misspelled or does not exist. (
<fizzbuzz>, for example, is not an XHTML tag.) - The tag is legal, but that particular browser does not support it.
An example of #2 is the <blink> tag. This tag works in Mozilla and in nearly all versions of Netscape Navigator. Safari and Internet Explorer do not support it.
This isn't a terrible loss. The <blink> tag is a very annoying tag that nobody misses.
