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

Learn how to validate your webpages with the W3C validator service.

Want to join the conversation?

  • piceratops seed style avatar for user Pancakeman44
    are there any other HTML Validation sites out there? if so, are they better or worse than validator.w3.org?
    (16 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Ibraheem
    Do you have to pay for validation?
    (5 votes)
    Default Khan Academy avatar avatar for user
  • duskpin sapling style avatar for user matilda.bertoli
    Pamela, how do you find a code on a webpage?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • sneak peak green style avatar for user 𝒮𝑒𝓉𝒾𝓂𝒾𝓉𝒾
    What are the 2 warnings? How come Pamela didn't pay attention to them?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • duskpin sapling style avatar for user Ruby Phoenix [inactive]
      Pamela ignored the warnings because a warning is different from an error. An error stops your code from working properly. A warning is just a minor problem with the code. The code will work fine even with those minor problems, though it would be better to fix them.
      I can't say what the warnings were without actually running the code in the validator. :)
      (8 votes)
  • blobby green style avatar for user matej1simko
    What do I do if it says i havent completed the lesson?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Daniel
    I did that with one of my webpages but I got this warning.

    Warning: This document appears to be written in English. Consider adding lang="en" (or variant) to the html start tag.

    From line 1, column 16; to line 2, column 6

    TYPE html>↩<html>↩<head

    For further guidance, consult Declaring the overall language of a page and Choosing language tags.

    If the HTML checker has misidentified the language of this document, please file an issue report or send e-mail to report the problem.

    what does it mean?
    (3 votes)
    Default Khan Academy avatar avatar for user
  • hopper cool style avatar for user Jasmine
    I type validtor.w3.org but it says that the site cannot be reached, but other sites can be reached
    (1 vote)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user Josiah Pond
    How do I get to this validation site? Or another one that does the same thing and is free?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • spunky sam blue style avatar for user Dalendrion
      Hi Josiah!

      Thanks for your question.
      Unfortunately I can't give you the link to the website, since Khan Academy doesn't allow links in comments anymore.
      But if you look at Pamela's browser, you can see the address at the top.

      You can also go to Google and search for "HTML validator". The first search result is "The W3C Markup Validation Service". That's what you're looking for.
      (2 votes)
  • stelly orange style avatar for user totoro
    I used the <time> tag and wrapped it up in <ul>.

    The HTML validatpr says -
    *Error: Element time not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)*

    So how can I specify machine-readable time while inside a list?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • hopper cool style avatar for user Luke Fisher
    so lets say i want to change the color of div1 when i hover over div2, how would i do that? here is the code i tried

    #div1:hover #div2 {

    (2 votes)
    Default Khan Academy avatar avatar for user
    • aqualine ultimate style avatar for user William Chargin
      Hi! Yeah, like Jamthom8 says, you'll need to use JavaScript for that. But we now do have a jQuery tutorial! Check it out here: https://www.khanacademy.org/computing/computer-programming/html-js-jquery

      Here's a bit more info about why that doesn't work. CSS is actually quite limited in what you can select. For example, you also can't say "make an element red when its child element is hovered," which seems quite reasonable. It might seem even more surprising that while you can say "make this element is red when my next sibling is selected," you can't say "make this element red when my previous sibling is selected"! Why all these restrictions?

      The answer is that CSS can get pretty complicated as it is, and browsers need to be really good at scanning the CSS and applying your rules really fast. Because of the restrictions on the CSS, the browser only needs to look through your CSS once. That is, it never has to "backtrack" and say "okay, this selector matches, so now I go back to that element I saw before and…" because that's just too complicated to be fast enough.

      The (yet unreleased) CSS4 specification has a few nice additions. But those might change between now and the time it's released.

      So, yeah, go for jQuery!
      (2 votes)

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.