Good Authoring Practices

This section offers some guidelines for writing “good” HTML documents—markup that will be supported by a wide variety of browsers, handled easily by browsers expecting correct syntax, and extensible to emerging technologies built on the current HTML specification.

Choose elements that accurately and meaningfully describe the content

Making sure that your document is semantically sound improves accessibility under the wide range of web browsing environments. If something is a list, mark it up as a list. If you don’t want bullets, it’s not a problem. You can use a style sheet to change the presentation of the list to be anything you want, be it bullet-less or a graphical horizontal navigation bar (see Chapter 24 for this technique).

Avoid choosing elements based on the way that they render in the browser.

For example, don’t use a blockquote just to achieve indented text and don’t use a series of brs or <p>&nbsp;</p> for extra whitespace. Again, you can use a style sheet for such presentational effects.

Avoid using deprecated elements and attributes.

This is actually a round-about way of saying “use style sheets instead of presentational HTML,” because most elements and attributes have been deprecated in favor of style sheet controls.

Write compliant, valid documents.

Even if you are using HTML 4.01, it is a good idea to follow the XHTML Recommendations for a compliant, valid document. Although once it was fine to omit closing tags and quotation marks, browsers in ...

Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.