Skip to content

Getting Started

1. Use npm or yarn to install HTMLHint:

npm install --save-dev htmlhint

2. Create a .htmlhintrc configuration file in the root of your project with htmlhint --init. This will create a file with default rules. You can customize it as needed. For example, you can use the following configuration to enforce some common best practices:

{
"alt-require": true,
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-value-double-quotes": true,
"button-type-require": true,
"doctype-first": true,
"doctype-html5": true,
"frame-title-require": true,
"h1-require": true,
"html-lang-require": true,
"id-unique": true,
"main-require": true,
"meta-charset-require": true,
"meta-description-require": true,
"meta-viewport-require": true,
"spec-char-escape": true,
"src-not-empty": true,
"tag-no-obsolete": true,
"tag-pair": true,
"tagname-lowercase": true,
"title-require": true
}

3. Run HTMLHint on, for example, all the HTML files in your project:

Terminal window
npx htmlhint "**/*.html"