Could I check invalid HTML tag?

Could I check invalid HTML tag? For example, I want to use <form>, but I input <forum>
or I want to use <input type="text" name="foo"> but I input <input type="text" na me="foo"> (there is a space in ‘na me’.

Hi,

not sure, if there’s a rule checking for blanks / typos in attributes.
You might check the available HTML rules

Gilbert

In order to check the validity of your HTML code, you could use a validator. For example, for Visual Studio Code, there are extensions such as W3C Validation.

If you are already using Node.js, you could install the Node package html-validator-cli:

npm i html-validator-cli -g

You can then validate files on the command line using a syntax such as

html-validator --file=<path-to-file>

Thanks, I try some amazing tools like HTML validator, HTML hint, LintHtml, … they are good.
But I cannot find a tool can integrate into SonarQube, because ‘new code’ feature is important.
It’s really hard to modify all old code, but we can use ‘new code’ to check what’s wrong in the recent version.

Don’t know nothing about those html validators.
For Sonarqube 9.9 LTS and Sonarqube 10.3 Latest there is no entry for import from a third party html validator in the documentation.

Sonarqube 9.9 LTS

Sonarqube 10.3

Maybe there’s a way to import their reports via generic issue format !?

Sonarqube 9.9 LTS

Sonarqube 10.3, the generic issue format has changed

Hi all,

This is an old topic, but I think it makes a lot of sense.

I think Sonar could help in detecting invalid HTML, including invalid tags for the reason @Dennys_Hsieh explains, i.e. typos.

HTML is excessively tolerant of what it accepts, so something like this could be helpful.

I created a ticket to track this potential feature:
https://sonarsource.atlassian.net/issues/SONARHTML-223

Kind regards,