HTML Validation Tutorials and Tools

There are all sorts of rules in HTML. For example: Did you know that the <title> element must to be inside the <head> element? Or that every <img> must have an alt attribute?

If you've been using HTML for a long time, you are probably familiar with most of these rules. Some, though, are a little obscure. Other have changed since earlier versions of HTML.

HTML validation is the process of making sure that your HTML is well-formed. That is, it checks to see if it conforms to the specification and does not break any of these rules.

Tutorials on HTML Validation

Online HTML Validators

  • The W3C Markup Validation Service is the authoritative HTML validator, maintained by the World Wide Web Consortium, the standards body that manages the HTML specification. You can use the tool to validate a live site, an uploaded file, or via direct form input. There's even an API, so that you can connect to the validator from your own tools.

  • The Nu Validator allows you to validate the content of a live URL, an uploaded file, or pasted text. You can validate against several standard schemas, or against your own. The Nu Validator is describes as "an experiment", but it is quickly becoming the new standard, and even the W3C hosts an implementation of it.

  • OnlineWebCheck validates HTML, and also performs a number of other checks such as CSS validation and checking the cache manifest. They also have a downloadable desktop app for Windows.

  • This HTML/XML Validator at arbola.net offers the option to show suggested repairs for any HTML errors.

  • WDG HTML Validator is a validator from the Web Design Group that can be used for individual or batch URLs. It provides more feedback than the W3C's canonical validator for technically valid, but potentially problematic, HTML.

Validation Tools for Local Use

These are validation tools that can be downloaded and installed locally or on your own server. Some of them are standalone applications, and some are libraries and extensions which can be included into other projects.

  • The Nu HTML Checker, mentioned above, can be downloaded and run locally as a Java app. There are integrations with Grunt, Travis CI, Gulp and other tools, which makes it easy to integrate Nu into any development and deployment workflow. Nu Validator is also behind the clever Let Me Validate That For You tool, which auto-validates HTML included in code samples that are linked to GitHub issues.

  • Tidy (or "HTML Tidy") is a cross-platform console application that corrects and cleans up HTML. It doesn't just point out errors — it actively fixes your code. At the core of the HTML Tidy project is libtidy, a C library that can be included into nearly any application. Most contemporary programming languages have at least one wrapper for libtidy.

  • HTML Validator for Firefox and Mozilla is a browser extension that displays the number of HTML errors on a page.

  • Html-Validator is a Node.js module for validating HTML using the Nu HTML Checker.

  • W3C HTML Validator by Micheh is a PHP library that uses the W3C Validator API.

  • Validator Suite by the W3C is a Java application that provides a set of validation tools that can be run locally. The suite is built on Play Framework and MongoDB. Active development of the suite has ended, but the project is open source, and W3C is encouraging interested developers to fork the project.

  • Total Validator develops set of tools, including a paid product and a free desktop app. The tools perform several types of HTML validation. It also checks for broken links and bad spelling.

  • HTML Validator Browser Add-On for Firefox automatically validates every page you visit and displays the number of validation errors in a small icon at the top of your browser.

  • Django Output Validator automatically validates HTML generated by a Django app, keeping a log of any pages that fail validation. This is done in real time, as pages are requested (not at deployment).

  • CSE HTML Validator for Windows is a commercial software product that does validation on HTML and CSS and performs a number of other checks, such as accessibility, SEO, broken links, and spelling.

Does Validation Really Matter?

It's easy to feel like validation doesn't really matter, especially if you know that Google's home page contains a whole bunch of validation errors. And so does Facebook. And YouTube.

In fact, we tested the top 10 most popular sites on the web, and every single one of them had validation errors.

So, is it worth bothering?

Yes.

It is safe to assume that the engineers at Google, Facebook, and Amazon all know what they are doing, and routinely test their front-end output.

Those pages are the way they are because of a relentless and never-ending process of optimization. This is something you, on your site, probably do not have the ability to do.

HTML Validation lets you know if there are any potential problems in your markup. It's a little bit like spell-checker. You may have some specific reason for not fixing an error, but most of the errors are typos and mistakes that really do need to get fixed.

The goal is not to get zero errors from an HTML validation tool. The goal is to have clean markup that renders properly in every browser and can be well-understood by search engines. HTML Validation is one useful step in pursuit of that goal.


Further Reading and Resources

We have more guides, tutorials, and infographics related to coding and website development:

HTML for Beginners — Ultimate Guide

If you really want to learn HTML, we've created a book-length article, HTML for Beginners — Ultimate Guide.

And it really is the ultimate guide; it will take you from the very beginning to mastery.