-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IMG tag: Omitting the sizes attribute when using width descriptors should be deemed correct. #7116
Comments
The current requirement is an author-level requirement, and I believe still has value; it's not obvious from inspection that We've still gotta do something with the image when the attribute isn't present, so folding it into the general error-handling is fine, but I think it should still be considered an error by validators. |
Like @tabatkins said, this is a document conformance requirement intended to help web developers be mindful about providing a correct |
Perhaps it can be resolved by adding a small note or warning saying that user agents will default the |
Hi, could I work on this?
(adding a note below saying that) "User agents will default the sizes attribute to 100vw if it is missing but validators should generate an error on its omission." |
That seems ok, though note that #8008 makes Also, notes shouldn't use normative keywords ("should"), use "will" instead. |
https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-srcset
We should have the option to omit the
sizes
attribute and allow the user agent to default this attribute to100vw
. According to the algorithm given at the following link, user agents already do this. The absence ofsizes
attribute is considered as an empty string, and when parsing the empty string, no sizes are found, hence the default value of100vw
is returned:https://html.spec.whatwg.org/multipage/images.html#parsing-a-sizes-attribute
However, the above quoted text is confusing to readers as it implies that the attribute must always be present (when using width descriptors in the
srcset
attribute) otherwise the HTML code of the<img>
tag is deemed incorrect. I believe the HTML code of the<img>
tag should still be deemed correct even if thesizes
attribute is not present in such case. In its absence, the user agent falls back to assuming it to be100vw
and this behavior should be expected as a correct behavior.The omission of
sizes
attribute is most useful for images that span the full width of the viewport (the so-called hero images).The text was updated successfully, but these errors were encountered: