Share via


Validating HTML/HTML5 Document

Validating a HTML document means checking or verifying its code according to the standards of HTML5 specifications. For validating an HTML5 document we can use an HTML validator. These are programs that check HTML documents for conformance to to the standards. Some common online HTML validator programs:

  1. http://validator.w3.org/

  2. http://validator.whatwg.org/

Use the following procedure to validate the HTML document (FirstHTMLpage.html):

  1. Open a browser and URL http://validator.w3.org ).

    http://www.c-sharpcorner.com/UploadFile/79037b/validating-an-htmlhtml5-document/Images/Validating-an-HTML-Document-1.jpg

  2. Select the "Validate by Direct Input" tab and add the HTML code of the FirstHTMLpage.html file in the provided area.
    (We can also upload the respective HTML file document directly or By URL).

  3. Click the check button. If the code complies with the HTML5 standards then the validator displays the results accordingly:

    http://www.c-sharpcorner.com/UploadFile/79037b/validating-an-htmlhtml5-document/Images/Validating-an-HTML-Document-2.jpg

  4. Click the "Check" button ant note that if your document does not meet the standards of HTML5 then the errors occur, like :

    http://www.c-sharpcorner.com/UploadFile/79037b/validating-an-htmlhtml5-document/Images/Validating-an-HTML-Document-3.jpg

  5. You can remove all the errors by using this platform:

    http://www.c-sharpcorner.com/UploadFile/79037b/validating-an-htmlhtml5-document/Images/Validating-an-HTML-Document-4.jpg

About Validation Wiki

The About Validation Wiki says:

"The Markup Validation Service is a validator by the World Wide Web Consortium (W3C) that allows Internet users to check HTML and XHTML documents for well-formed markup. Markup validation is an important step towards ensuring the technical quality of web pages; however, is not a complete measure of web standards conformance. Though W3C validation is important for browser compatibility and site usability, it has not been confirmed what effect it has on search engine optimization." [w3.org]

Why to Validate

The w3c gives an answer.

"Validation as a debugging tool

While contemporary Web browsers do an increasingly good job of parsing even the worst HTML "tag soup", some errors are not always caught gracefully. Very often, various software on various platforms will not handle errors in a similar fashion, making it extremely difficult to apply style or layout consistently.

Using standards, interoperable markup and stylesheets, on the other hand, offers a much greater chance of having one's page handled consistently across platforms and user-agents. Indeed, most developers creating rich Web applications know that reliable scripting needs the document to be parsed by User-Agents without any unexpected error, and will make sure that their markup and CSS is validated before creating a rich interactive layer.

When surveyed, a large majority of Web professionals will state that validation errors is the first thing they will check whenever they run into a Web styling or scripting bug." [w3.org]

"Validation as a future-proof quality check

Checking that a page "displays fine" in several contemporary browsers may be a reasonable insurance that the page will "work" today, but it does not guarantee that it will work tomorrow.
In the past, many authors who relied on the quirks of Netscape 1.1 suddenly found their pages appeared totally blank in Netscape 2.0. Whilst Internet Explorer initially set out to be bug-compatible with Netscape, it too has moved towards standards compliance in later releases.
Validation is one of the simplest ways to check whether a page is built in accordance with Web standards, and provides one of the most reliable guarantees that future Web platforms will handle it as designed.
" [w3.org]

"Validation eases maintenance

It is reasonable to consider that standards such as HTML and CSS are a form of "coding style" that is globally agreed upon. Creating Web pages or applications according to a widely accepted coding style makes them easier to maintain, even if the maintenance and evolution is performed by someone else." [w3.org]

"Validation helps teach good practices

Many professionals have been authoring the Web with HTML and CSS for years and know these technologies by heart. Beginners and students, on the other hands, will find automated checking tools invaluable in spotting mistakes. Some teachers also stress that automated validation tests are a good introduction to broader, more complex quality concepts such as accessibility." [w3.org]

"Validation is a sign of professionalism

As of today, there is little or no certification for Web professionals, and only few universities teach Web technologies, leaving most Web-smiths to learn by themselves, with varied success. Seasoned, able professionals will take pride in creating Web content using semantic and well-formed markup, separation of style and content, and so on. Validation can then be used as a quick check to determine whether the code is the clean work of a seasoned HTML author, or quickly hacked-together tag soup." [w3.org]