DEV Community

Habdul Hazeez
Habdul Hazeez

Posted on • Edited on

3 1

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

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more