https://github.com/html-validate/html-validate
Mirror of the HTML-Validate GitLab repository
https://github.com/html-validate/html-validate
devtools hacktoberfest html html-checker html-linter html-validate html-validation web-development web-standards
Last synced: 10 months ago
JSON representation
Mirror of the HTML-Validate GitLab repository
- Host: GitHub
- URL: https://github.com/html-validate/html-validate
- Owner: html-validate
- License: mit
- Created: 2023-08-20T22:14:03.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-04-12T21:59:29.000Z (10 months ago)
- Last Synced: 2025-04-12T22:33:48.968Z (10 months ago)
- Topics: devtools, hacktoberfest, html, html-checker, html-linter, html-validate, html-validation, web-development, web-standards
- Language: TypeScript
- Homepage: https://html-validate.org
- Size: 63.4 MB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# html-validate
[](https://gitlab.com/html-validate/html-validate/commits/master)
[](https://gitlab.com/html-validate/html-validate/commits/master)
Offline HTML5 validator. Validates either a full document or a smaller
(incomplete) template, e.g. from an AngularJS or Vue.js component.
Read the full documentation at https://html-validate.org/
## Features
- Can test fragments of HTML, for instance a component template.
- Does not upload any data to a remote server, all testing is done locally.
- Strict and non-forgiving parsing. It will not try to correct any incorrect
markup or guess what it should do.
## Usage
npm install -g html-validate
html-validate [OPTIONS] [FILENAME..] [DIR..]
## Configuration
Create `.htmlvalidate.json`:
```js
{
"extends": [
"html-validate:recommended"
],
"rules": {
"close-order": "error",
"void": ["warn", {"style": "omit"}]
}
}
```
## Example
```html
Click me!
Lorem ipsum
```
```text
1:1 error Element
is implicitly closed by adjacent
no-implicit-close
2:2 error Button is missing type attribute button-type
6:4 error Unexpected close-tag, expected opening tag close-order
```
## Bundles
The library comes in four flavours:
- CommonJS full (`dist/cjs/index.js`)
- CommonJS browser (`dist/cjs/browser.js`)
- ESM full (`dist/es/index.js`)
- ESM browser (`dist/es/browser.js`)
The browser bundle contains a slimmed version without CLI and NodeJS dependencies.
```ts
/* automatically determine build based on `browser` export condition */
import { ... } from "html-validate";
/* explicitly use nodejs bundle */
import { ... } from "html-validate/node";
/* explicitly use browser bundle */
import { ... } from "html-validate/browser";
```
See [running in browser](https://html-validate.org/dev/running-in-browser.html) for details about getting HTML-Validate running in a browser environment.
## Developing
### Prerequisites
- NodeJS 18
- NPM 7
### Test
Testing is done using jest.
npm test
or call `jest` directly.
Some tests are autogenerated from documentation examples, use `npm run docs` to build those before running.
### Lint
Linting is done using ESLint.
npm run eslint
or call `eslint` directly.
### Build
npm run build
To build documentation use:
npm run docs
The documentation can be served locally using:
npm start