BUY THIS BOOK
Add to Cart

Print Book $12.99


Add to Cart

Print+PDF $16.89

Add to Cart

PDF $10.99

Safari Books Online

What is this?

Add to UK Cart

Print Book £8.99

What is this?

Looking to Reprint or License this content?


HTML and XHTML Pocket Reference
HTML and XHTML Pocket Reference, Third Edition By Jennifer Niederst Robbins
May 2006
Pages: 104

Cover | Table of Contents


Table of Contents

Chapter 1: HTML and XHTML Pocket Reference
This pocket reference provides a concise yet thorough listing of the elements and attributes specified in the HTML 4.01 and XHTML 1.0 Recommendations. The text uses the shorthand "(X)HTML" for concepts that apply to both markup standards.
This book is organized into the following sections:
  • HTML and XHTML Fundamentals
  • Alphabetical List of Elements
  • Character Entities
  • Specifying Color
HTML (HyperText Markup Language) is the markup language used to turn text documents into web pages. The fundamental purpose of HTML as a markup language is to provide a semantic description (the meaning) of the content and establish a document structure (a hierarchy of elements). It is not concerned with presentation, such as how the document will look in a browser. Presentation is the job of Cascading Style Sheets, which is outside the scope of this book. The current version of HTML is defined in the HTML 4.01 Recommendation.
XHTML (eXtensible HyperText Markup Language) is a reformulation of HTML 4.01 according to the stricter syntax rules of XML (eXtensible Markup Language). The elements are the same, but there are additional restrictions for document markup, as listed in the next section. XHTML includes a family of Recommendations, including XHTML 1.0, XHTML 1.1, Modularization of XHTML, XHTML Basic, and other versions still in development. This reference focuses on the XHTML 1.0 Recommendation. For details on all versions of HTML and XHTML, see the World Wide Web Consortium's HTML home page at www.w3.org/MarkUp.
Because XHTML is an XML language, its syntax is more strict and differs from HTML in these key ways:
  • All element and attributes must be lowercase. For example, <a href="example.com"> . . . </a>.
  • All elements must be terminated--that is, they must include an end tag. For example, <p> . . . </p>.
  • Empty elements must be terminated as well. This is done by including a slash at the end of the tag. A space is commonly added before the slash for backward compatibility with older browsers. For example, <hr />, <img />, <meta />.
  • All attribute values must be contained in quotation marks (either single or double). For example,
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
HTML and XHTML Fundamentals
HTML (HyperText Markup Language) is the markup language used to turn text documents into web pages. The fundamental purpose of HTML as a markup language is to provide a semantic description (the meaning) of the content and establish a document structure (a hierarchy of elements). It is not concerned with presentation, such as how the document will look in a browser. Presentation is the job of Cascading Style Sheets, which is outside the scope of this book. The current version of HTML is defined in the HTML 4.01 Recommendation.
XHTML (eXtensible HyperText Markup Language) is a reformulation of HTML 4.01 according to the stricter syntax rules of XML (eXtensible Markup Language). The elements are the same, but there are additional restrictions for document markup, as listed in the next section. XHTML includes a family of Recommendations, including XHTML 1.0, XHTML 1.1, Modularization of XHTML, XHTML Basic, and other versions still in development. This reference focuses on the XHTML 1.0 Recommendation. For details on all versions of HTML and XHTML, see the World Wide Web Consortium's HTML home page at www.w3.org/MarkUp.
Because XHTML is an XML language, its syntax is more strict and differs from HTML in these key ways:
  • All element and attributes must be lowercase. For example, <a href="example.com"> . . . </a>.
  • All elements must be terminated--that is, they must include an end tag. For example, <p> . . . </p>.
  • Empty elements must be terminated as well. This is done by including a slash at the end of the tag. A space is commonly added before the slash for backward compatibility with older browsers. For example, <hr />, <img />, <meta />.
  • All attribute values must be contained in quotation marks (either single or double). For example, <td colspan="2">.
  • All attribute values must be explicit and may not be minimized to one word, as is permitted in HTML. For example:
    • checked="checked"
    • selected="selected"
    • multiple="multiple"
  • Nesting restrictions are more strictly enforced. These restrictions are explicitly stated:
    • An a element cannot contain another a element.
    • The pre element cannot contain
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Alphabetical List of Elements
This section contains a listing of all elements and attributes in the HTML 4.01 and XHTML Recommendations, as well as a few nonstandard elements.
Readers are advised to watch for these labels on elements and attributes:
Deprecated
Elements and attributes marked as Deprecated are being phased out of HTML—usually in favor of Cascading Style Sheets—and are discouraged from use. All deprecated elements and attributes have been removed from the Strict versions of HTML and XHTML.
Required
Attributes marked as Required must be included in the element for the markup to be valid.
XHTML only
Attributes marked XHTML only apply only to documents marked up in XHTML. Other minor differences between HTML and XHTML are noted similarly.
Nonstandard
Nonstandard elements and attributes are not included in any version of the HTML or XHTML Recommendations but are well-supported by browsers.
A number of attributes in the HTML 4.01 and XHTML 1.0 Recommendations are shared by nearly all elements. To save space, they have been abbreviated in this reference as they are in the Recommendations. This section explains each attribute's shorthand and serves as a reference for the remainder of the element listing.

Core

When Core is listed under Attributes, it refers to the set of core attributes that may be applied to the majority of elements (as noted in each element listing):
id
Assigns a unique identifying name to the element
class
Assigns one or more classification names to the element
style
Associates style information with an element
title
Provides a title or advisory information about the element

Internationalization

When Internationalization appears in the attribute list, it means the element accepts the set of attributes used to specify language and reading direction:
dir
Specifies the direction of the element (left to right or right to left).
lang
Specifies the language for the element by its language code.
xml:lang
XHTML only. Specifies language for elements in XHTML documents.

Events

When Events is listed for the element, it indicates that the core events used by scripting languages are applicable to the element. Additional events that are not part of the core events are listed separately:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Character Entities
Characters not found in the normal alphanumeric character set, such as < and &, must be specified in HTML and XHTML documents using character references. This process is known as escaping the character. In (X)HTML documents, escaped characters are indicated by character references that begin with & and end with ; . The character may be referred to by its Numeric Character Reference (NCR) or a predefined character entity name.
A Numeric Character Reference refers to a character by its Unicode code point in either decimal or hexadecimal form. Decimal character references use the syntax &#nnnn; . Hexadecimal values are indicated by an "x": &#xhhhh; . For example, the less-than (<) character could be identified as &#60; (decimal) or &#x3C (hexadecimal).
Character entities are abbreviated names for characters, such as &lt; for the less-than symbol. Character entities are predefined in the DTDs of markup languages such as HTML and XHMTL as a convenience to authors because they may be easier to remember than Numeric Character References.
HTML and XHTML documents use the standard 7-bit ASCII character set in their source. The first 31 characters in ASCII (not listed) are such device controls as backspace (&#08; ) and carriage return (&#13; ) and are not appropriate for use in HTML documents.
HTML 4.01 defines only four entities in this character range—less than (<, &lt; ), greater than (<, &gt; ), ampersand (&, &amp; ), and quotation mark (", &quot; )—that are necessary for escaping characters that may be interpreted as markup. XHTML also includes the &apos; entity that is included in every XML language. In XHTML documents, the ampersand symbol (& ) must always be escaped in attribute values. For better compatibility with XML parsers, authors should use numerical character references instead of named character references for all other character entities.
Numeric character entities may also be represented by their hexadecimal equivalents. Hexadecimal values are preceded by an x . For example, the hexadecimal character reference for the less-than symbol is written &#x3C;.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Specifying Color
Because color is presentational, it should be specified with Cascading Style Sheets, not in the (X)HTML document. In both (X)HTML and CSS, color values may be provided by numeric values or standardized color names.
The most common and precise way to specify a color is by its numeric RGB (red, green, blue) values. Using an image-editing tool such as Adobe Photoshop, you can determine the RGB values (on a scale from 0 to 255) for a selected color. For example:
Red: 212 Green: 232 Blue: 119
These values must be converted to their hexadecimal (base-16) equivalents in order to be used as attribute values. In this example, the previous decimal values are converted to hexadecimal.
Red: D4 Green: E8 Blue: 77
In (X)HTML, these values are provided in a six-character string, preceded by the # symbol, like so:
#D4E877
The underlying syntax is this:
#RRGGBB
where RR stands for the hexadecimal red value, GG stands for the hexadecimal green value, and BB stands for the hexadecimal blue value.
Fortunately, Adobe Photoshop makes the hexadecimal values for colors readily available at the bottom of the color picker next to the # symbol. The hex values can be copied from the color picker and pasted into a stylesheet or HTML document.
If you are using an image tool that does not list hexadecimal values, you'll need to convert decimal to hexadecimal yourself using a hexadecimal calculator. Windows users can find a hexadecimal calculator in the "Scientific" view of the Windows standard calculator. Mac users with OS X 10.4 (Tiger) can download the free Hex Calculator Widget at:
Colors may also be identified by predefined color names. The syntax for using color names is extremely straightforward.
<body link="navy">
HTML 4.01 and XHTML 1.0 include 16 valid color names. They are listed here with their equivalent RGB values:
black
#000000
green
#008000
silver
#C0C0C0
lime
#00FF00
gray
#808080
olive
#808000
white
#FFFFFF
yellow
#FFFF00
maroon
#800000
navy
#000080
red
#FF0000
blue
#0000FF
purple
#800080
teal
#008080
fuchsia
#FF00FF
aqua
#00FFFF
These color names may be used with stylesheets as well. The CSS 2.1 Recommendation adds
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!

Return to HTML and XHTML Pocket Reference