Is auto
a valid value for the HTML attributes height
and width
?
Please provide a reputable source. I was unable to find a reputable source saying yes or no (i.e. specifically settling this issue one way or the other).
(I know that style="width:auto"
is valid CSS.
But my question is about the HTML <img>
tag.)
2
Answers
For reference, the W3 validator says that
auto
is an invalid value:input:
output:
"Error: Bad value auto for attribute height on element img"
The HTML living standard specification attributes index says that for each, the value must be a Valid non-negative integer.
This is defined as
Note however, that the attributes index is non-normative. For the normative requirement, the definition of the attribute on each element must be checked.
For example on the
<img>
element the text says:So since "auto" does not consist of one or more ASCII digits, it is not valid.