-2

I am trying to check HTML 5 files for validity and have found the W3C validator. However I have found that this validator accepts grossly wrong HTML documents like this one:

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>Hello World</title>
    Hello
</body>
</html>

Here I have removed the opening html tag, and the opening body tag and the validator reports:

The document validates according to the specified schema(s).

I do not assume, that this document is anyhow compliant to the HTML 5 or any other HTML standard. Obviously the validator is not very strict, when it comes to nesting of elements or opening/closing tags.

Is there a more strict validator out there, which reports every tiny deviation from standard HTML?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Harry Berry
  • 318
  • 1
  • 10
  • You can ask that W3C validator to check against e.g. HTML 4.01 Strict, which does show errors. Just pick the appropriate doctype on https://validator.w3.org/#validate_by_input+with_options. – jonrsharpe Apr 08 '21 at 08:06
  • Thanks, True That. That does the trick for html 4. I have changed the title - I need to check html5 files. – Harry Berry Apr 08 '21 at 08:12
  • 1
    I don't think that _is_ "grossly wrong" as HTML5, see e.g. https://stackoverflow.com/q/9797046/3001761 – jonrsharpe Apr 08 '21 at 08:13

1 Answers1

1

I do not assume, that this document is anyhow compliant to the html5 or any other html standard.

But you are assuming that it isn't compliant. You could check by reading the standard.

See, for example, the html element:

Tag omission in text/html:
An html element's start tag can be omitted if the first thing inside the html element is not a comment.
An html element's end tag can be omitted if the html element is not immediately followed by a comment.


Is there a more strict validator out there, which reports every tiny deviation from standard html?

While tool recommendations are off-topic for this site, there are no deviations from standard html in the code you've presented.

The Nu validator is very good at what it does.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335