Configuration
By default, HTMLHint looks for a .htmlhintrc file in the current directory and all parent directories, and applies its rules when parsing a file:
htmlhint index.htmlTo provide a custom configuration file to the command, use the --config option:
htmlhint --config htmlhint.conf index.htmlCustom rules can also be specified individually, via the --rules option:
htmlhint --rules tag-pair,id-class-value=underline index.htmlFinally, rules can be specified inline directly in the HTML document:
<!-- htmlhint tag-pair,id-class-value:underline --><html> <head>...</head> <body>...</body></html>Disabling Rules Inline
Section titled “Disabling Rules Inline”You can disable specific rules or all rules for specific lines in your HTML using HTML comments. This is useful when you need to temporarily disable linting for a particular section of code.
Disable All Rules
Section titled “Disable All Rules”To disable all HTMLHint rules for the following lines until re-enabled:
<!-- htmlhint-disable --><div class="foo">Lorem</div><div class="bar">Ipsum</div><!-- htmlhint-enable --><div class="baz">Dolor</div>Disable for Next Line
Section titled “Disable for Next Line”To disable all rules for just the next line:
<!-- htmlhint-disable-next-line --><div class="foo">Lorem</div><div class="bar">Ipsum</div>Disable Specific Rules
Section titled “Disable Specific Rules”To disable specific rules for the following lines:
<!-- htmlhint-disable attr-lowercase --><div CLASS="foo">Lorem</div><div CLASS="bar">Ipsum</div><!-- htmlhint-enable --><div class="baz">Dolor</div>Disable Specific Rules for Next Line
Section titled “Disable Specific Rules for Next Line”To disable specific rules for just the next line:
<!-- htmlhint-disable-next-line attr-lowercase --><div CLASS="foo">Lorem</div><div class="bar">Ipsum</div>Disable Multiple Rules
Section titled “Disable Multiple Rules”You can disable multiple rules by listing them separated by spaces:
<!-- htmlhint-disable attr-lowercase tagname-lowercase --><DIV CLASS="foo">Lorem</DIV><div class="bar">Ipsum</div>Example configuration file
Section titled “Example configuration file”An example configuration file (with all rules disabled):
{ "alt-require": false, "attr-lowercase": false, "attr-no-duplication": false, "attr-no-unnecessary-whitespace": false, "attr-sorted": false, "attr-unsafe-chars": false, "attr-value-double-quotes": false, "attr-value-no-duplication": false, "attr-value-not-empty": false, "attr-value-single-quotes": false, "attr-whitespace": false, "button-type-require": false, "doctype-first": false, "doctype-html5": false, "empty-tag-not-self-closed": false, "form-method-require": false, "frame-title-require": false, "h1-require": false, "head-script-disabled": false, "href-abs-or-rel": false, "html-lang-require": false, "id-class-ad-disabled": false, "id-class-value": false, "id-unique": false, "inline-script-disabled": false, "inline-style-disabled": false, "input-requires-label": false, "link-rel-canonical-require": false, "main-require": false, "meta-charset-require": false, "meta-description-require": false, "meta-viewport-require": false, "script-disabled": false, "space-tab-mixed-disabled": false, "spec-char-escape": false, "src-not-empty": false, "style-disabled": false, "tag-no-obsolete": false, "tag-pair": false, "tag-self-close": false, "tagname-lowercase": false, "tagname-specialchars": false, "tags-check": false, "title-require": false}VS Code Configuration
Section titled “VS Code Configuration”To have your configuration file recognized by editors with JSON schema support, you can add the following to VS Code settings (.vscode/settings.json). This will enable autocompletion and validation for the .htmlhintrc file.
{ "json.schemas": [ { "fileMatch": ["/.htmlhintrc"], "url": "https://json.schemastore.org/htmlhint.json" } ]}Note: if you have the VS Code extension installed, it will automatically recognize the .htmlhintrc file without needing to add this configuration.