Section 8.7. Good Authoring Practices


8.7. Good Authoring Practices

This section offers some guidelines for writing "good" HTML documentsmarkup 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 the future may not be so forgiving.


Validate your HTML.

To be absolutely sure about how you're doing conformance-wise, you should run your HTML code through an HTML validator, such as the one at the W3C site (validator.w3.org). For a list of other validator services, see The Web Design Group page at www.htmlhelp.com/links/validators.htm.


Avoid extra returns and character spaces.

These extra keystrokes add to the size of your document because blank spaces are transmitted just like all other characters. Not only that, line breaks and extra spaces can create unwanted whitespace in certain contexts. For instance, extra spaces within and between table cells (td elements) can add unwanted spaces in a table. Adding a line break between consecutive img elements will introduce whitespace between the images. It is best to keep your file as compact as possible.


Use comments to delineate sections of markup so that you can find them quickly.

HTML documents can get long and complicated. Adding comments to label portions of the document can make things easier to find at a glance and may allow you to keep the document compact without a lot of extra space.


Follow proper filenaming conventions.

Consider these guidelines:

  • Use the proper HTML document suffix .html or .htm. Suffixes for a number of common file types can be found in Table 4-1.

  • Avoid spaces and special characters such as ?, %, #, and so on in filenames. It is best to limit filenames to letters, numbers, underscores (in place of spaces), hyphens, and periods.

  • Filenames may be case-sensitive on your server. Consistently using all lowercase letters in filenames, although certainly not necessary, may help avoid confusion and make them easier to remember.

  • Keep filenames as short as possible. Extra characters add to the file size of the document.




Web Design in a Nutshell
Web Design in a Nutshell: A Desktop Quick Reference (In a Nutshell (OReilly))
ISBN: 0596009879
EAN: 2147483647
Year: 2006
Pages: 325

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net