html
HTML files: valid structure, accessibility, and no inline scripts or event handlers. Guide: HTML.
Selected when
Section titled “Selected when”A scope has file extensions .html or .htm. Also when site requires it.
Checks
Section titled “Checks”html-validate
Section titled “html-validate”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.
What to do
Section titled “What to do”Change the markup the way the rule page says.
Example
Section titled “Example”An <img src="logo.png"> without alternative text reports a finding. Add alt text, or leave it empty for a decorative image.
Turn it off
Section titled “Turn it off”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] -->inline-scripts
Section titled “inline-scripts”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.
What to do
Section titled “What to do”Move the script into its own file, and attach the handler there. Structured data of type application/ld+json stays inline.
Example
Section titled “Example”A button with an inline onclick attribute reports a finding. Remove it, and attach the listener from a script file.
Lint rules
Section titled “Lint rules”| 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. |
Turn it off
Section titled “Turn it off”gspot ignore html/inline-scripts --paths "<path>" --reason "<why>"gspot ignore html/inline-scripts --rule inline-script --reason "<why>"Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/HTML.md |
Always |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| html-validate | 11.16.2 |
Files gspot writes
Section titled “Files gspot writes”.gspot/configurations/html/html-validate.json