HTML The Definitive Guide (22 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
5.27Mb size Format: txt, pdf, ePub

Chapter 3

Anatomy of an HTML

Document

 

3.3 HTML Tags

For the most part, HTML document tags are simple to understand and use, since they are made up of common words, abbreviations, and notations. For instance, the and tags tell the browser respectively to start and stop italicizing the text characters that come between them. Accordingly, the syllable "simp" in our barebones HTML example would appear italicized on a browser display.

The HTML standard and its various extensions define how and where you place tags within a document. Let's take a closer look at that syntactic sugar that holds together all HTML documents.

3.3.1 The Syntax of a Tag

Every HTML tag consists of a tag
name
, sometimes followed by an optional list of tag
attributes
, all placed between opening and closing brackets (< and >). The simplest tag is nothing more than a name appropriately enclosed in brackets, such as and . More complicated tags contain one or more attributes, which specify or modify the behavior of the tag.

Tag and attribute names are not case-sensitive. There's no difference in effect between , , , or even ; they are all equivalent. The values that you assign to a particular attribute may be case-sensitive, however, depending on your browser and server. In particular, file location and name references - universal resource locators (URLs) - are case-sensitive.

[Referencing Documents: The URL, 7.2]

Tag attributes, if any, belong after the tag name, each separated by one or more tab, space, or return characters. Their order of appearance is not important.

A tag attribute's value, if any, follows an equal sign (=) after the attribute name. You may include spaces around the equal sign, so that width=6, width = 6, width =6, and width= 6 all mean the same. For readability, however, we prefer not to include spaces. That way, it's easier to pick out an attribute/value pair from a crowd of pairs in a lengthy tag.

If an attribute's value is a single word or number (no spaces), you may simply add it after the equal sign. All other values should be enclosed in single or double quotation marks, especially those values that contain several words separated by spaces. The length of the value is limited to 1024 characters.

Most browsers are tolerant of how tags are punctuated and broken across lines. Nonetheless, avoid breaking tags across lines in your source document whenever possible. This rule promotes readability and reduces potential errors in your HTML documents.

3.3.2 Sample Tags

Here are some tags with attributes:

Other books

The Pricker Boy by Reade Scott Whinnem
Corruption of Blood by Robert Tanenbaum
The Book of Heaven: A Novel by Patricia Storace
Homecoming by Cynthia Voigt
A Very Russian Christmas by Krystal Shannan
Raising Kane by James, Lorelei
Pretenders by Lisi Harrison
Arm Candy by Jill Kargman

© FullEnglishBooks 2015 - 2024    Contact for me [email protected]