Validating code

A short guide to how and why you should validate your code.

Validating code

Hello everybody, I’m Matt from Nomensa and I’m here to talk about how and why you should validate your code.

Validating code has been part of the Web Content Accessibility Guidelines since version 1, and whilst browsers have got better at understanding poor code, it is still important to test and validate your HTML thoroughly.

There are a few different services that will validate your HTML. The most popular is the W3C’s Validation Service. This tool allows you to easily enter a URL, upload a file or paste code directly into the validator.

So why is validating code important? Firstly it should help you reach a wider audience. Both old and new browsers should read the valid code and display the page correctly, without errors. The same applies for users of assistive technologies such as screen readers.

Secondly, valid code is a sign of well structured code and helps to ensure we are all following the same standards. The top validation errors published by show that developers fall for the same coding errors time and time again, all of which can be identified and fixed by using a validator.

So, are there any exceptions to producing valid code? Well sometimes you might intentionally use invalid code to improve the user’s experience. For example, you might notice that by including ARIA landmark roles in a HTML4 document creates some errors. However, because we are knowingly improving the user’s experience, without introducing any actual issues, we might be inclined to accept this error as a false positive.

Ultimately, knowing and understanding the code syntax will allow you to resolve many of the issues you find when validating your code and over time will improve both the quality of your code, as well as help to prevent possible issues a user might get from a poorly coded site.

Add a comment

Fields marked with an asterisk (*) are mandatory.