
An example of this is a block element like appearing as the child of an inline element like. Validate Element Location: Make sure that elements don't appear as children of parents they're not allowed to descend from. Any element you don't want to be warned about can be whitelisted. This will catch simple things like misspelled tags ( instead of ), and it will inform you of deprecated tags (like, , and more recently ). Validate Elements: Inspects each element in the DOM and reports any elements that are invalid or obsolete. (Expect this list to get more comprehensive in the future.) Here are the validation rules that ship with HTML Inspector. That being said, there is still a lot that it can do (and does) to validate your markup. Because HTML Inspector runs after the browser has parsed your HTML, any mistakes the browser has forgiven will not be seen by HTML Inspector.Īs a result HTML Inspector should not be seen as a replacement for validation. This makes it a lot more powerful, but there are some drawbacks as well. Validators parse static markup, while HTML Inspector runs on a live DOM.

HTML Inspector is different than a markup validator. The following is a more in-depth explanation of each rule: Validation Here are the default configuration values: The function is passed an array of errors that were reported by individual rules. onComplete: (Function) the callback to be invoked when the inspection is finished.excludeSubTrees: (selector | element | Array) the descendants of any DOM element that matches the selector, element, or list of selectors/elements will be excluded from traversal.excludeElements: (selector | element | Array) any DOM element that matches the selector, element, or list of selectors/elements will be excluded from traversal (note: its descendants will still be traversed).If useRules and excludeRules are both set, the excluded rules are removed from the list of rules to use. excludeRules: (Array) a list of rule names not to run when inspecting.

Defaults to running all rules not excluded via excludeRules

It's also easy to extend, allowing teams to write their own rules to enforce their chosen conventions.įor a more formal introduction, please refer to this blog post which goes into more detail as to why HTML Inspector was created and why you should consider using it. HTML Inspector is opinionated, but every rule is completely customizable, so you can take what you like and change what you don't. It aims to find a balance between the uncompromisingly strict W3C validator and having absolutely no rules at all (the unfortunate reality for most of us).

#HTML INSPECTOR W3 CODE#
HTML Inspector is a highly-customizable, code quality tool to help you (and your team) write better markup. If anyone else would like to take over as a maintainer, please contact me. ⚠️ NOTE: I no longer have time to maintain this project, respond to issues, or address PRs.
