Skip to main content

HTML code validation

Validating HTML means testing html code for errors and checking that it complies with the HTML standard defined by the W3C.

HTML validation is not an exact art. Browsers are often forgiving when dealing with invalid markup, so invalid HTML doesn't always mean that your website is broken for your users.

However, validation errors can often flag potential bugs.

What is HTML validation?

Checking HTML validation errors is a quick way to find possibly unintended behavior in your code.

For example, the error below highlights that an empty src attribute was supplied for an img tag.

Empty image src attribute

There's also a "duplicate attribute" message on the same element. In this case the two class attributes have the same value, so nothing should break because of this.

Duplicated class attributes

Warnings from the HTML validator are usually not very important and can be ignored. For example, it's not necessary to specify the type of a style tag as text/css, but it doesn't hurt either.

HTML validator attribute warning

W3C Markup Validation service

You can use the W3C HTML Validator to run a one-off test on a URL.

W3C HTML validation result

Monitoring HTML validation

DebugBear validates your HTML code as part of every test and keeps track of the number of errors and warnings.

You can see the results in the Validation tab of your page results.

HTML validation errors and warnings

By default, low-priority errors and warnings are hidden. Untick Hide low-priority messages to view the full validation result.

You can expand each entry to see a detailed error message and a snippet from the page HTML.

In the example below the image has two class attributes. As a result one of them will be ignored by the browser.

Detailed HTML validation error