Videos
W3C Validator alternatives for broken HTML?
html - Javascript Validation w3c - Stack Overflow
What is the W3C VALIDATOR?
Validator.w3.org
I've always used the W3C Validator to help find broken HTML elements, but I'm finding it's becoming quite outdated and throwing errors for things that are now valid.
Are there any better alternatives to finding broken HTML elements?
Use CDATA sections. The < has a special meaning for the parser.
Copy<script>
//<![CDATA[
...JavaScript code..
//]]></script>
The validator has detected a <, and attempts to parse a new tag <q.length. When the semicolon is spotted, the parser don't know how to handle it, and throws an error. By using CDATA, you effectively say "Anything inside this section should be interpreted as plain-text, and not be parsed.
Paste your code at http://validator.w3.org/check (validate by direct input), using the following settings: "Validate Document fragment, XHTML 1.0".
If you move your javascript functions into an external file, and then link to that file from your page head section, then the validator doesn't have to worry about them.
e.g.
Copy<script src="functions.js" type="text/javascript"></script>
This also allows you to reuse functions across multiple pages without repeating the code.
A further benefit is that the user's browser will cache the js file the first time it encounters it, so on subsequent pages the javascript functions file will be retrieved from cache, rather than being downloaded with the page.
» npm install w3c-html-validator
Hello this is willijkm speaking. actually i read a book about html and in a chapter of this book speak about W3C VALIDATOR but i don't quiet understand it, Can you help me? Thanks.
» npm install html-validator
Because I have not. It always felt like a throwback to the early days of HTML, and with the (necessary) forgiving nature of browsers, it rarely reaches the front of my mind. Chasing accessibility, style updates, color contrast, page weight, security testing, end-to-end testing, 100 other things,... it just never rises to the top. Some of the findings feel pedantic (only accepted text values of a `<date>` tag), some feel worthwhile (duplicate IDs on a page).
Curious about others' experiences.