HTML The Definitive Guide (28 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

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

Chapter 3

Anatomy of an HTML

Document

 

3.9 The Tag

As we've mentioned earlier, the authors of the latest HTML standard have made a concerted effort to include standard ways web agents (browsers) are supposed to treat and display the many different human languages and dialects. Accordingly, the HTML 4.0 standard contains the universal dir and lang attributes that let you explicitly advise the browser that the whole document or specific tagged segments within it are in a particular language. These language-related attributes, then, may effect some display characteristics; for example, the dir attribute tells the browser to write the words across the display from either left to right (dir=ltr), as for most Western languages, or right to left (dir=rtl), as for many Asian languages.
[The dir attribute, 3.5.1.1] [The lang attribute, 3.5.1.2]

However, the various Unicode and ISO standards for language encoding and display may conflict with your best intentions. In particular, the contents of some other documents, such as a MIME-encoded file, you may embed in your own already may be properly formatted and your HTML

document may misadvise the browser to undo that encoding. Hence, the HTML 4.0 standard has the tag. With it, you override any current and inherited dir specifications. And with the tag's required dir attribute, you definitively specify the direction by which the tag's contents should be displayed.

Admittedly, the effects of the tag are a bit esoteric and the opportunities to use it currently are rare, particularly considering that no popular browser yet supports it.


Function:

Overrides bidirectional algorithms for content display Attributes:

DIR

LANG

End tag:

; never omitted

Contains:

text

Used in:

body_content

3.8 Editorial Markup

4. Text Basics

Chapter 4
4. Text Basics
Contents:

Divisions and Paragraphs

Headings

Changing Text Appearance

Content-based Style Tags

Physical Style Tags

Expanded Font Handling

Precise Spacing and Layout

Block Quotes

Addresses

Special Character Encoding

Any successful presentation, even a thoughtful tome, should have its text organized into an attractive, effective document. Organizing text into attractive documents is HTML's forte. The language gives you a number of tools that help you mold your text and get your message across. HTML also helps structure your document so that your target audience has easy access to your words.

Always keep in mind while designing your documents (here we go again!) that HTML tags, particularly in regard to text, only advise - they do not dictate - how a browser will ultimately render the document. Rendering varies from browser to browser. Don't get too entangled with trying to get just the right look and layout. Your attempts may and probably will be thwarted by the browser.

4.1 Divisions and Paragraphs

Like most text processors, a browser wraps the words it finds in the HTML text to fit the horizontal width of its viewing window. Widen the browser's window and words automatically flow up to fill the wider lines. Squeeze the window and words wrap downwards.

Unlike most text processors, however, HTML uses explicit division (

), paragraph (

), and line-break (
) tags to control the alignment and flow of text. Return characters, although quite useful for readability of the source HTML document, typically are ignored by the browser - HTML

authors must use the
to explicitly force a common text line break. The

tag, while also performing the task, carries with it meaning and effects beyond a simple line break.

The

tag is a little different. Originally codified in the HTML 3.2 standard,
was included in the language to be a simple organizational tool - divide the document into discrete

sections - whose somewhat obtuse meaning meant few authors used it. But recent innovations -

alignment, styles, and the id attribute for document referencing and automation - now let you more distinctly label and thereby define individual sections of your HTML documents, as well as control the alignment and appearance of those sections. These features breathe real life and meaning into the

tag.

By associating an id and a class name with the various sections of your HTML document, each delimited by a

name
> tag and attributes (you can do the same with other tags like

, too), you not only label those divisions for later reference by a hyperlink and for automated processing and management (collect all the bibliography divisions, for instance), but you may also define different, distinct display styles for those portions of your document. For instance, you might define one divisional class for your document's abstract (

, for example), another for the body, a third for the conclusion, and a fourth divisional class for the bibliography (
, for example).

Each class, then, might be given a different display definition in a document-level or externally related style sheet: the abstract indented and in an italic typeface (such as DIV.abstract {leftmargin: +0.5in; fontstyle: italic}); the body in a left-justified roman typeface; the conclusion similar to the abstract; and the bibliography automatically numbered and formatted appropriately.

We provide a detailed description of style sheets, classes, and their applications in
Chapter 9,

Cascading Style Sheets.

4.1.1 The

Tag

As defined in the HTML 4.0 standard, the

tag divides your document into separate, distinct sections. It may be used strictly as an organizational tool, without any sort of formatting associated with it; it becomes more effective if you add the id and class attribute to label the division. The
tag may also be combined with the align attribute to control the alignment of whole sections of your document's content in the display, and with the many programmatic "on" attributes for user interaction.

Other books

Mexican WhiteBoy by Matt de la Pena
An Accidental Sportswriter by Robert Lipsyte
A Heart Revealed by Julie Lessman
Miss Garnet's Angel by Salley Vickers
The Heart of Mine by Amanda Bennett
Not Mine to Give by Laura Landon
The Long Cosmos by Terry Pratchett
Two Bits Four Bits by Mark Cotton

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