HTML The Definitive Guide (22 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
10.11Mb 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

Byron in Love by Edna O'Brien
Transhuman by Mark L. Van Name, T. K. F. Weisskopf
Paradime by Alan Glynn
Forbidden by Lauren Smith
A New Life by Bernard Malamud
Diario. Una novela by Chuck Palahniuk
Nerds Are From Mars by Vicki Lewis Thompson
DEATH IN PERSPECTIVE by Larissa Reinhart
After Tuesday by Ericson, Renee

© 100 Vampire Novels China Edition 2015 - 2024    Contact for me [email protected]