Double-Quoted Attribute Values
ID |
html.attr_value_double_quotes |
Severity |
info |
Remediation Complexity |
low |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Code Smell |
Language |
Html |
Tags |
code_smell |
Description
Flags an element whose attribute carries a value that is not wrapped in double quotes — either an unquoted value or a single-quoted value.
Rationale
HTML allows attribute values to be unquoted or single-quoted, but mixing quoting styles is a readability and maintenance hazard: unquoted values break the moment a space or special character is added, and inconsistent quoting makes the markup harder to scan and edit safely. Settling on double quotes everywhere is the conventional, robust choice.
<a href='/p'>x</a> <!-- FLAW — single-quoted value -->
<input type=text> <!-- FLAW — unquoted value -->
<a href="/p">y</a> <!-- OK — double-quoted value -->
<input disabled> <!-- OK — bare attribute, no value -->
Remediation
Wrap every attribute value in double quotes, e.g. type="text" and href="/p". Bare attributes
without a value need no quoting.