If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

HTML validation

Browsers can be forgiving and might still display a webpage even if there are errors in the code. However, to ensure your webpage works consistently across different browsers, it's a good idea to validate your HTML using the W3 validation service. Let's walk through how to use the W3C validator service and fix common errors, like missing alt attributes for images.

Want to join the conversation?

Video transcript

- [Voiceover] On Khan Academy, we pop up the oh noes guide to tell you when there's something wrong with your webpage. But we only tell you about the big things. There could be other things wrong with your webpage too, things that aren't quite right according to the HTML specification. But the browsers let you get away with it because browsers like to be really forgiving. They just want to make it work. So then you end up not knowing that there's something wrong with your webpage. That's why it's a good idea to run your webpage through the W3 validation service. That will actually check and tell you if your page is valid and if there's something not quite right about it. To do that, go to validator.w3.org. It'll give you options to enter a URL, upload a file, or just copy and paste. That's what I'll do. I'll take the most recent webpage that I was showing in a talk through and paste it in here and then check. Ta-da! It was successfully checked as HTML 5 and there were no issues with it. Fantastic. Let's try one more. This is our HTML internal links example. I want to paste this in here and check. Uh-oh, there was one error, two warnings. Let's go down. It says that an image element must have an alt attribute. Uh-oh, this is a classic thing to forget is that alt attribute. We see the images, but not everybody does. So what I should do is go back into that HTML and add the alt attribute. So let's say the image was here, alt equals photo of Tim Berners-Lee next to computer and let me copy and go back up, paste. I will re-validate. Ta-da! It's valid HTML. When possible, you should be trying to make webpages that are valid HTML because that way you can have a lot more confidence that the browser is going to interpret them exactly like you expect all the time. Now go try and validate a few of your pages and see how they turn out.