DEV Community

Habdul Hazeez
Habdul Hazeez

Posted on • Updated on

Validating HTML documents

Data validation is a means of confirming the integrity and correctness of data, just like in other fields, tools are employed for this in HTML.

There are paid products out there for validating HTML documents and there are free options which are the route we will be taking. But the question that might come to your mind is: why validate HTML?

Mistakes do happen when you code and there is a high chance you did not close a tag, you left out a required attribute or your open and closing quotes do not match and due to the forgiving nature of HTML you might not notice this error.

If the HTML document you are working on is quite sizeable you can use the browser viewsource and visually hunt down the errors which are highlighted in red and using your mouse to hover these error you'll get brief information about the error which most of the time is what the browser thinks you (the developer) should have done.

viewsource in firefox

This approach is not practical if the document is quite enormous. The W3C has a validator that's free to use and it's available online. There are three methods for validating your data using this tool:

  • Validation by URI
  • Validation by file upload
  • Validation by direct input

VALIDATION BY URI

This method of validation allows you to submit the URL of the document (the website address) you want to check and the tool will do the rest.

Validation By URI with the W3C Validator

VALIDATION BY FILE UPLOAD

In this approach, you upload a local HTML file to the validator

Validation By file upload with the W3C Validator

VALIDATION BY DIRECT INPUT

If the document you want to check is minute, this option is practical. In this regard, you copy the HTML source code and paste it into the validator and then validate it.

Validation By Direct Input with the W3C Validator

Below is an image that show's a minimal validation result by URI

A site validated with W3C Validator

Top comments (0)