HTMLHint 工具能夠對 HTML 代碼作靜態代碼檢查,從而保證 HTML 代碼的規範和質量。HTMLHint 工具內置 23 條規則,建議在 .htmlhintrc
配置文件中將規則儘量都打開:javascript
{ "tagname-lowercase": true, "attr-lowercase": true, "attr-value-double-quotes": true, "attr-value-not-empty": true, "attr-no-duplication": true, "doctype-first": true, "tag-pair": true, "tag-self-close": true, "spec-char-escape": true, "id-unique": true, "src-not-empty": true, "title-require": true, "alt-require": true, "doctype-html5": true, "id-class-value": "dash", "style-disabled": true, "inline-style-disabled": true, "inline-script-disabled": true, "space-tab-mixed-disabled": "space4", "id-class-ad-disabled": true, "href-abs-or-rel": false, "attr-unsafe-chars": true, "head-script-disabled": true }
每一個規則的具體含義,請見下一篇文章htmlhint 規則詳解html