Help and FAQ for the Markup Validator

Nothing wrong with the validator here, it just knows HTML better than you do. -- David Dorward, Validator's mailing-list.

Table of contents

  1. About the Markup Validator
    1. Help me! I clicked on an icon and ended up on this strange site!
    2. What is Markup Validation?
    3. Is validation some kind of quality control? Does "valid" mean "quality approved by W3C"?
    4. Is validity the same thing as conformance?
    5. What is the Markup Validator and what does it do?
    6. Why validate?
    7. Who owns/maintain the Markup Validator?
    8. What other validators are there?
    9. How does The Validator work?
    10. How do I send feedback/bug reports about the Markup Validator?
  2. Using this service
    1. How do I use the Markup validator?
    2. What is (are) this (these) error message(s)?
    3. Many error messages? Don't panic.
    4. I don't want error messages, I want you to clean up my page!
    5. "valid" icons
      1. My document is valid, can I use your "valid" icon?
      2. Is there a list of all available icons somewhere?
      3. Why do I see warnings about "insecure items" when viewing my page after including the icon?
      4. License and Guidelines for usage of the "valid" icons
      5. Can I modify the existing icons to create my own?
      6. I saw the "valid" icon displayed on a site but the page is invalid. What should I do?
  3. Miscellaneous (Very) Frequently Asked Questions
    1. No DOCTYPE Declaration Found!
    2. No Character Encoding Found!
    3. How can I include flash in valid (X)HTML Web pages?
    4. The validator complains about "&" in my URLs!
    5. The validator complains about something in my JavaScript!
    6. Why doesn't the validator like my <link ... /> or <meta ... />?
    7. I found some nasty typo like <p<a ...> and the validator accepted it!
    8. /check?uri=referer does not work or the validator says it does not support my "undefined" URL scheme
    9. Can the validator check all the pages in my site in one batch?

About the Markup Validator

Help me! I clicked on an icon and ended up on this strange site!

Don't panic!

The author of the Web page you come from once used our service to validate that page, and the page passed validation. The author was then authorized to use the icon on that page, as a claim of validity. The icon is used as a link back to the validation service, so that the author can revalidate whenever necessary. This is why, by clicking on the icon, you followed a link to the current validation results for the page you came from.

The validation result was certainly positive ("this page is valid..."), but if it wasn't, you would probably do the author of the page where the icon was a favor if you could warn him/her of this abnormal situation.

If you are curious about Markup validation you may read this help document further, or you may simply use the back button of your Web browser to come back to the page where you found the "valid" icon.

What is Markup Validation?

Most pages on the World Wide Web are written in computer languages (such as HTML) that allow Web authors to structure text, add multimedia content, and specify what appearance, or style, the result should have.

As for every language, these have their own grammar, vocabulary and syntax, and every document written with these computer languages are supposed to follow these rules. The (X)HTML languages, for all versions up to XHTML 1.1, are using machine-readable grammars called DTDs, a mechanism inherited from SGML.

However, Just as texts in a natural language can include spelling or grammar errors, documents using Markup languages may (for various reasons) not be following these rules. The process of verifying whether a document actually follows the rules for the language(s) it uses is called validation, and the tool used for that is a validator. A document that passes this process with success is called valid.

With these concepts in mind, we can define "markup validation" as the process of checking a Web document against the grammar (generally a DTD) it claims to be using.

Is validation some kind of quality control? Does "valid" mean "quality approved by W3C"?

Validity is one of the quality criteria for a Web page, but there are many others. In other words, a valid Web page is not necessarily a good web page, but an invalid Web page has little chance of being a good web page.

For that reason, the fact that the W3C Markup Validator says that one page passes validation does not mean that W3C assesses that it is a good page. It only means that a tool (not necessarily without flaws) has found the page to comply with a specific set of rules. No more, no less. This is also why the "valid ..." icons should never be considered as a "W3C seal of quality".

Is validity the same thing as conformance?

No, they are different concepts.

Markup languages are defined in technical specifications, which generally include a formal grammar. A document is valid when it is correctly written in accordance to the formal grammar, whereas conformance relates to the specification itself. The two might be equivalent, but in most cases, some conformance requirements cannot be expressed in the grammar, making validity only a part of the conformance.

What is the Markup Validator and what does it do?

The Markup Validator is a free tool and service that validates markup: in other words, it checks the syntax of Web documents, written in formats such as (X)HTML.

The Validator is sort of like lint for C. It compares your HTML document to the defined syntax of HTML and reports any discrepancies.

Learn more about the Markup Validator and the languages it can validate.

Why should I validate my HTML pages?

One of the important maxims of computer programming is: Be conservative in what you produce; be liberal in what you accept.

Browsers follow the second half of this maxim by accepting Web pages and trying to display them even if they're not legal HTML. Usually this means that the browser will try to make educated guesses about what you probably meant. The problem is that different browsers (or even different versions of the same browser) will make different guesses about the same illegal construct; worse, if your HTML is really pathological, the browser could get hopelessly confused and produce a mangled mess, or even crash.

That's why you want to follow the first half of the maxim by making sure your pages are legal HTML. The best way to do that is by running your documents through one or more HTML validators.

A lengthier answer to this question is also available on this site if the explanation above did not satisfy you.

Who owns/maintain the Markup Validator?

The Markup Validator is maintained at W3C by W3C staff and benevolent collaborators, who receive a lot of help from contributors (read the full credits).

What other validators are there?

We're doing our best to provide clear and reliable results as well as a good interface with the Markup Validator, but for some reason you may want to check other validators. Here are a few choices:

Looking for validators at W3C, but not the Markup Validator? Check out the list of validators at W3C, including well-known CSS validator, link checker, etc.

How does The Validator work?

The Validator is based on OpenSP, an SGML parser based on James Clark's SP SGML parser. The Validator itself is a CGI script that (basically) fetches your document, passes it through the parser, and post-processes the resulting error list for easier reading.

How do I send feedback/bug reports about the Markup Validator?

Read the instructions on our Feedback page.

Using this service

How do I use this service?

Most probably, you will want to use the online Markup Validation service. The simple way to use this service to validate a Web page is to paste its address into the text area on the validator's home page, and press the "Check" button.

There are other possible uses and a few usage options, please read the user's manual for further help with this service.

If, for some reason, you prefer running your own instance of the Markup Validator, check out our developer's documentation.

What are these error messages?

The output of the Markup Validator may be hard to decipher for newcomers and experts alike, so we are maintaining a list of error messages and their interpretation, which should help.

Many error messages? Don't panic.

Don't panic. Did The Validator complain about your DOCTYPE declaration (or lack thereof)? Make sure your document has a syntactically correct DOCTYPE declaration, as described in the section on DOCTYPE, and make sure it correctly identifies the type of HTML you're using. Then run it through The Validator again; if you're lucky, you should get a lot fewer errors.

If this doesn't help, then you may be experiencing a cascade failure — one error that gets The Validator so confused that it can't make sense of the rest of your page. Try correcting the first few errors and running your page through The Validator again.

Be patient, with a little time and experience you will learn to use the Markup Validator to clean up your HTML documents in no time.

I don't want error messages, I want you to clean up my page!

Have a look at tools such as HTML Tidy and tidyp. When selected, the "Clean up Markup with HTML-Tidy" option will output a "cleaned" version of the input document in case it was not valid, done with HTML-Tidy, using the Markup Validator's default HTML-Tidy configuration. Note that there are no guarantees about the validity or other aspects of that output, and there are many options to configure in these tools that may result in better clean up than the Validator's default options for your document, so you may want to try out them locally.

"valid" icons

My document is valid, can I use your "valid" icon?

Valid XHTML 1.0! Yes. To show readers that one has taken some care to create an interoperable Web page, a "W3C valid" badge may be displayed (here, the "valid XHTML 1.0" badge) on any page that validates.

We encourage you to use the XHTML code below (or its HTML equivalent), but you may use a different code to integrate the icon within your web page as long as the icon is used as a link to revalidate the Web page it is in. Sample code is as follows:

   <p>
      <a href="http://validator.w3.org/check?uri=referer"><img
          src="http://www.w3.org/Icons/valid-xhtml10"
          alt="Valid XHTML 1.0!" height="31" width="88" /></a>
    </p>
  
Is there a list of all available icons somewhere?

The full list of "valid" icons is available on the W3C website.

Why do I see warnings about "insecure items" when viewing my page after including the icon?

Many browsers display this warning when viewing documents transferred over a secure protocol such as HTTPS if the documents contain items that are transferred over a non-secure protocol such as unencrypted HTTP. As W3C does not currently provide the "valid" icons over HTTPS, you may want to copy and serve the icons from a HTTPS enabled server elsewhere and link to those copies instead of the W3C originals in your documents that are transferred over a secure protocol to avoid this warning. See also HTTPS related documentation in the "/check?uri=referer" FAQ entry.

License and Guidelines for usage of the "valid" icons

Web content providers are granted the right to use the "W3C valid" logo on pages that pass validation (through the use of the W3C Markup Validator) for the W3C technology represented by the icon, and only on pages that pass validation. The icon must be used as a link to revalidate the Web page, thus providing a way to verify the page author's assertion that it passed validation.

Note that "W3C Valid" icons are not an endorsement by the W3C of the page's author, the substantive content of the page, nor its design. Instead, the icons are only a mechanism to identify pages that have been determined to be valid, and to easily revalidate pages as often as as they are modified.

Consequently, the use of the badge is in accordance with and governed by the W3C Trademark License and Logo and Icon usage policy.

Can I modify the existing icons to create my own?

No. The validator's icons are distributed under the W3C document license, which allows distribution but does not allow derivative works.

I saw the "valid" icon displayed on a site but the page is invalid. What should I do?

We recommend that you write to the site manager and politely bring to that person's attention that there is an inconsistency. Please note that W3C does not verify or attempt to enforce validity claims.

Miscellaneous (Very) Frequently Asked Questions

No DOCTYPE Declaration Found!

A DOCTYPE Declaration is mandatory for most current markup languages and without one it is impossible to reliably validate a document.

One should place a DOCTYPE declaration as the very first thing in an HTML document. For example, for a typical XHTML 1.0 document:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
        <head>

          <title>Title</title>
        </head>

        <body>
          <!-- ... body of document ... -->
        </body>

      </html>
    

For XML documents, you may also wish to include an "XML Declaration" even before the DOCTYPE Declaration, but this is not well supported in older browsers. More information about this can be found in the XHTML 1.0 Recommendation.

The W3C QA Activity maintains a List of recommended Doctypes that you can choose from, and the WDG maintains a document on "Choosing a DOCTYPE".

No Character Encoding Found!

An HTML document should be served along with its character encoding.

Specifying a character encoding is typically done by the web server configuration, by the scripts that put together pages, and inside the document itself. IANA maintains the list of official names for character encodings (called charsets in this context). You can choose from a number of encodings, though we recommend UTF-8 as particularly useful.

The W3C I18N Activity has collected a few tips on how to do this.

To quickly check whether the document would validate after addressing the missing character encoding information, you can use the "Encoding" form control (accesskey "2") earlier in the page to force an encoding override to take effect. "iso-8859-1" (Western Europe and North America) and "utf-8" (Universal, and more commonly used in recent documents) are common encodings if you are not sure what encoding to choose.

How can I include flash in valid (X)HTML Web pages?

Many Flash authoring tools recommend, or enforce, the usage of the <embed> element to include flash animations or applications in Web pages. <embed>, however, was never part of any standardized version of HTML, and this practice produces invalid markup.

There are many techniques to incorporate flash in valid web pages. One of the most famous is the Flash Satay technique.

The validator complains about "&" in my URLs!

Most probably, you should read the ampersand section of WDG's excellent "common validation problems" document.

The validator complains about something in my JavaScript!

Most probably, you should read the script section of WDG's excellent Common HTML Validation Problems document.

Why doesn't the validator like my <link ... /> or <meta ... />?

HTML is based on SGML and uses an SGML feature (called SHORTTAG) (note that this is not the case with XHTML).

With this feature enabled, the "/" in <link ... /> or <meta ... /> already closes the link (or meta) tag, and the ">" becomes some regular text, which is not allowed in the <head> element. Since </head><body> is optional in HTML (again, not in XHTML), it is silently inserted, thus head-only elements like meta and style as well as "</head>" and "<body>", which may appear only once, become false.

(explanation courtesy of Christoph Päper)

I found some nasty typo like <p<a ...> and the validator accepted it!

This again (as in the previous case) comes from the SHORTTAG feature in HTML (not in XHTML). The typo is actually a "shorthand markup" and is a valid construct in HTML, even though its use is not recommended.

/check?uri=referer does not work - or - the validator says it does not support my "undefined" URL scheme

Browsers and other Web agents usually send information about the page they come from, in a Referer header. The validator uses this information for a features that allows it to validate whatever page the browser last visited. The "valid" icons on some Web page usually point to the validation of the page using this feature.

Unfortunately, some zealous "security software" or Web proxies strip the referrer information from what the browser sends. Without this information the validator is not able to find what the URL of the document to validate is, and gives the same error message as when it is given a type of URL it does not understand.

Also, requests to non-secure HTTP resources from links in documents transferred with a secure protocol such as HTTPS should not include referrer information per the HTTP/1.1 specification. As the validator at validator.w3.org is currently not available over HTTPS, this referrer feature will not work reliably for documents transferred over secure protocols (usually https URLs) with it.

How to fix: