HTML Basics
Stanford University Libraries & Academic Information Resources

Common Problems

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]

Here are some of the common problems that you can avoid:

Using <P> as 'separator' rather than container.
This was legal in earlier versions of HTML and since browser writers are urged by the HTML specification to be lenient in what they accept, some browser may still be rendered suitably on current browsers, so you may not catch this just by looking at the output. An HTML validation service will flag this error.

Using Headings as if they were font designators
No matter how much one might wish to effect some control over the font or typesize used to display an element, there is no mechanism in HTML to achieve this (future versions of HTML may support style sheets which will address presentation issues). The following usage, not uncommon on the Web, is illegal and browser-specific;

 [Don't Do This' ]

<ul>
    <li><h1>Something I want Big</h1>
    <li><h1>Something else I want Big</h1>
    <li><h6>Something I want Small</h6>
    </ul>

Overlapping elements
A common error in which the start-tag of one element appears before the end-tag of a following element, e.g.

 [Don't Do This' ]

<h2>Chapter 2 <h3></h2>Section1</h2>

Text that is not 'contained' by an element.
In the body of your document, all text must be between the start and end tags of a 'container' element such as <p>, <address>, <blockquote>, <address>, or a List Item. In earlier versions of HTML, the following was an approved usage, but is now illegal:

 [Don't Do This' ]

<h2>raspail test</h2>
    A method of determining the presence of rosin size
    in paper. One drop of a strong solution of
    ordinary sugar is applied to the sheet, the excess
    being blotted after one minute. A drop of
    concentrated sulfuric acid is then applied, which
    turns the area treated a bright red color if rosin
    is present in the paper.

Skipping headings levels.
Since headings are intended to designate successive subdivisions of a section of text, it rarely makes sense to skip heading levels, and usually indicates that the author is trying to achieve a typographic effect rather than indicate the structure of the document. It is not actually illegal to do something like the following, but it almost always bad form.

 [Don't Do This' ]

<h2>The</h2>
    <h1>History</h1>
    <h5>of</h5>
    <h3>The</h3>
    <h1>World</h1>

Some exceptions to this general rule are unobjectionable

Misspelling an element name

Forgetting about case sensitivity
While case is not significant in element names, it is significant in entity references. For example, the entity reference &Uuml; represents the character Ü while &uuml; represents ü.

Case is also significant in attribute values, especially in the case of URLs:

    <img src="mybeautifulface.gif">

could be written

    <IMG SRC="mybeautifulface.gif">

but neither would mean the same thing as

    <img src="MyBeautifulFace.gif">

Putting highlighting tags outside heading tags
    Illegal:  <em><h2>The Question of Journals</h2></em>
    Legal:    <h2><em>The Question of Journals</em></h2>

Note that both examples violate an important principle: markup should be, whenever possible, indicate the structure or meaning of the text, not it's visual presentation. Presentation is the purview of the user, content of the author.

Putting <body> elements inside the <head> and vice versa.
<Title>, for example, must appear in the <head> and may never appear in the <body>. For <P> the situation is reversed. It may appear only in the <body>

Using nonexistent (obsolete or non-standard) elements, attributes
E.g. HTML does not have a 'center' tag (even though some browsers support it), so using <center> will cause your document to be nonconforming. Similarly, the <xmp> is no longer part of HTML; examplary text is now marked up using <pre>. The <u> (underline) element has also been removed from HTML.
Spaces, newlines or extraneous hyphens in URLs
These are often artifacts of a word processor's overzealous word-wrapping.

Using href instead of src
When using the <a> tag to link to an image, the href attribute is used to identify the URL of the image. When using <img> to insert an inline image, the src is used.

 [Previous Page]  [Tutorial Top]  [Tech Guide]  [Next Page]


Walter Henry
Stanford University Libraries and Academic Information Resources