Skip to content

html

HTML files: valid structure, accessibility, and no inline scripts or event handlers. Guide: HTML.

A scope has file extensions .html or .htm. Also when site requires it.

Validates HTML files for nesting, required attributes, and text alternatives.

Runs at the commit stage.

Each browser repairs broken markup differently, and a screen reader announces only what remains.

Change the markup the way the rule page says.

An <img src="logo.png"> without alternative text reports a finding. Add alt text, or leave it empty for a decorative image.

gspot ignore html/html-validate --paths "<path>" --reason "<why>"
gspot ignore html/html-validate --rule <rule> --reason "<why>"

To silence one place, write a comment such as:

<!-- [html-validate-disable-next no-inline-style -- reason: the email client strips classes] -->

Reports inline scripts, event handler attributes, and executable URLs in HTML files.

Runs at the commit stage.

A content security policy blocks injected code only when it leaves out unsafe-inline, and each inline script then needs a nonce or a hash.

Move the script into its own file, and attach the handler there. Structured data of type application/ld+json stays inline.

A button with an inline onclick attribute reports a finding. Remove it, and attach the listener from a script file.

Rule What it checks What to do
inline-script No <script> element holds executable code inline. Put the code in a .js file, and load it with <script src="...">.
handler-attribute No element has an event handler attribute, such as onclick. Call addEventListener in a script file, and remove the attribute.
script-link No URL attribute runs code through a javascript: URL or a data: URL of a script or a page. Load the code from a script file, and link to a real page.
gspot ignore html/inline-scripts --paths "<path>" --reason "<why>"
gspot ignore html/inline-scripts --rule inline-script --reason "<why>"
Rule file Installed when
.gspot/rules/HTML.md Always
Tool Version
html-validate 11.16.2

.gspot/configurations/html/html-validate.json