Gettings started
HTML-validate is an offline HTML5 validator.
Installation
Install using npm
:
npm install --save-dev html-validate
Create .htmlvalidate.json
:
{
"extends": [
"htmlvalidate:recommended"
],
}
Run with:
node_modules/.bin/html-validate yourfile.html
Configuration
extends
Configuration can be extended from sharable configuration.
{
"extends": [
"my-npm-package",
"./file'
],
}
Each package and file must export a valid configuration object.
rules
{
"rules": {
"some-rules": "severity",
"other-rule": ["severity", {"option": true}]
},
}
where severity can be one of:
"error"
(or2
) to give error."warn"
(or1
) to warn."off"
(or0
) to disable
Some options takes optional parameters when using the form ["severity",
OPTIONS]
.
See rules for a list of all available rules and options.
elements
For proper validation some metadata for each element is required, detailing in
which context it can be used, allowed/disallowed attributes, etc. If elements
is not specified it defaults to ["html5"]
which is a bundled collection for
all HTML5 elements.
{
"elements": [
"html5",
"my-npm-package",
"./file"
],
}
Each entry will try to load metadata from (search in following order):
- Named bundled metadata.
- NPM package with the same name.
- A local file, json or js. Path is relative to the configuration file.
See elements metadata for details about writing your own metadata.