HTML and CSS Reference
In-Depth Information
Chapter 15
Most Common Errors
Several factors should be considered to achieve web site validity. The code is written either manually or generated
automatically, and errors are inevitable. Errors occur in the markup, in the style sheet, in the XML files, in scripts, in
server settings, and so forth. By analyzing and learning the most common errors, many of them can be eliminated or
at least minimized. As a result, they can be recognized, identified, and corrected quickly and efficiently.
Even the most carefully created web pages can contain errors. In this chapter, you will learn about the most
common errors and their solutions. It is really beneficial to know them, because they occur rather frequently, and
learning how to correct them will decrease the time required for corrections and ease your standardization efforts.
Common Serving Errors
One of the most common serving errors is to serve XHTML as text/html . For many years, web browsers handled
XHTML markup as if it were HTML. This is known as the “dirty secret of XHTML.” Self-closing tags and other XHTML
specific notations were ignored, and XHTML documents were rendered by SGML parsers instead of XML parsers [1].
As a result, none of the beneficial features of XML was used.
In contrast, modern browsers support the proper MIME type. XHTML documents should be served as
application/xhtml+xml instead of text/html , as discussed in Chapter 4.
Common Markup Errors
Web designers should know all the common markup errors in order to easily identify, find, and correct them.
Incorrectly used elements, wrong document structure, incorrectly closed tags, missing alt attributes, directly
provided ampersand characters, ignored case sensitivity, nonunique identifiers, and misspelled keywords are among
the most common markup errors. Many of them are clearly indicated by markup validators and can be corrected
easily. Validators also provide useful hints on the correction. However, some errors can cause many others. For
example, a missing end tag for a division makes not only the document collapse in the browser but also the nesting to
become incorrect. Consequently, it might happen that an invalid document with 18 errors indicated by a validator has
2-3 errors only. So, do not be frightened by the initial number of errors!
Incorrectly Used Elements
As a golden rule, extended care must be taken to eliminate unnecessary containers in the markup. For example,
images positioned to the right side of the page with the text “wrapping around” can be styled directly instead of
putting them onto floating divisions. Another example is the p tag, which should be used for a paragraph container
and not for carriage return. Look at the (really bad) example shown in Listing 15-1.
 
Search WWH ::




Custom Search