Write Tag Names In Lowercase
ID |
html.tagname_lowercase |
Severity |
info |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Code Smell |
Language |
Html |
Tags |
code_smell |
Description
Flags an opening element whose tag name contains an uppercase ASCII letter, other than the small set of legitimately mixed-case SVG and MathML element names.
Rationale
HTML tag names are case-insensitive, but the convention is to write them in lowercase. Uppercase tag
names such as <DIV> read inconsistently, jar with the rest of the markup and are a common artefact
of copy-paste or generated code. The foreign-content elements of SVG and MathML (for example
linearGradient or feGaussianBlur) are genuinely camelCase and must be written exactly so; those
are allow-listed and never flagged.
<DIV>...</DIV> <!-- FLAW — uppercase tag name -->
<div>...</div> <!-- OK — lowercase tag name -->
<linearGradient></linearGradient> <!-- OK — legitimate camelCase SVG element -->
Remediation
Rewrite the tag name in lowercase; reserve mixed case for the SVG and MathML elements that the specification defines with camelCase names.