Re:JavaScript tool that validates your HTML and warns you in...
by kevingadd on Saturday June 15, 2013 @07:36PM
(#5886674)
Can you actually validate HTML from user mode javascript? Isn't the HTML that you can access from JS the result of the browser's parser doing various things to 'fix up' mangled/incorrect HTML, and map the HTML to the actual object model (tbody elements, for example)?
[ Parent
| on HN ]
Re:JavaScript tool that validates your HTML and warns you in...
by philipwalton on Saturday June 15, 2013 @07:47PM
(#5886699)
Yes, you are correct. It's impossible to validate HTML from DOM traversal alone because the browser has already parsed it and forgiven any errors it was able to. (I didn't choose this title and agree that it's a little misleading.)
Technically, you could validate the markup if you did an AJAX request for the current URL and parsed the result yourself; however, if your app is generated dynamically and rendered primarily client side, you'd be missing a lot of the alterations done by your JavaScript in that validation.
This is why I think both tools have their place.
I try address this issue in my blog post introducing HTML Inspector under the section "How is HTML Inspector different than the W3C Validator?" http://philipwalton.com/articles/introducing-html-inspector/