Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Taking_Your_Talent_to_the_Web.pdf
Скачиваний:
5
Добавлен:
11.05.2015
Размер:
9.91 Mб
Скачать

188 HOW: HTML, the Building Blocks of Life Itself: What Is Good Markup?

By contrast, relative links work on or offline, which enables you to keep one or more fully functioning web sites on your hard drive.

That was relatively painless, wasn’t it? Absolutely.

WHAT IS GOOD MARKUP?

Technically, good HTML is code that validates—that is, code that fully complies with current W3C standards and contains no errors. To make sure your HTML validates, run it through the W3C validator at validator.w3.org, a free service from those wonderful people who brought you the Web. For more on this topic, see “HTML Standards Compliance: Why Bother?” in the Web Developer’s Virtual Library (WDVL.com/Authoring/HTML/Standards/).

For the validator to work properly, you need to include a <DOCTYPE>. This is a simple declaration that specifies what kind of HTML (or other markup language) you are attempting to write. For instance:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>

This declares the document to be HTML 4.01 strict. HTML 4.01 strict emphasizes structure over presentation and balks at “deprecated elements” such as background colors in table cells, <FONT FACE>, <FRAMES>, and other stuff we’re supposed to do with CSS instead of in HTML.

Newer browsers such as IE5/Mac, Netscape 6, and Mozilla render HTML 4.01 strict documents according to web standards and use a “quirks” mode for older or unspecified document types to emulate rendering bugs in older browsers. The engineers responsible for these browsers applied these techniques to offer full standards support for new sites without breaking old sites that were written to the quirks of the companies’ older, nonstandardsoriented browsers. Those older browsers generally ignore the <DOCTYPE> declaration completely, but the validator requires it.

Taking Your Talent to the Web

189

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>

This <DOCTYPE> declares that the web page is written in HTML 4.01 transitional markup, which tolerates deprecated presentational HTML attributes (<FONT FACE>, for example) so that such documents will render correctly in older, less standards-compliant browsers. IE5/Mac, Netscape 6, Mozilla and IE 6 will render these documents the same way older browsers would. This affords web designers the ability to support older and newer browsers while making the transition from a buggy Web to one that relies on standards. (See the section, “The 18-Month Pregnancy” in Chapter 2 to understand why a transitional or interim period is accommodated in this way.)

Other <DOCTYPE>s include HTML 3.2, HTML 4.01 Frameset, and XHTML

Strict and Transitional.

What Is Sensible Markup?

Conceptually, good markup is code that gets out of its own way and helps communicate your message in the simplest, most intuitive way possible— just like good design.

Beginning writers use too many adjectives. Beginning designers use too many shapes, fonts, and colors. Beginning HTML authors often fall so in love with the medium that they forget to communicate. Instead, they cram every page with embedded MIDI (music) files, pointlessly scrolling JavaScript messages, huge full-color photographs, animated GIFs (flames and dripping blood are especially popular), and blinking and moving text, often in a dozen different font faces and sizes.

That is bad design, and (we think) bad markup, even if it validates—which is pretty unlikely because folks attracted to dripping blood animations tend not to spend much time learning about web standards.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]