-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Make <img> src and srcset attributes optional if the source set can be generated from previous sibling <source> elements #11313
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
Comments
That would also require a parent |
The |
The use case is to make it easier for authors to write (and read) code that generates compliant Given a list of source sets provided from a CMS. It is simpler to output a function renderPicture(sources) {
return `<picture>
${sources.map(s => `<source srcset="${s.srcset}" media="${s.media}" type="${s.type}" />`)}
<img alt="Description of image" loading=lazy sizes=auto />
</picture>`
} Given two image Ids, one for dark and one for light mode, outputting generated function renderPicture(lightId, darkId) {
return `<picture>
${types.map(type => `<source srcset="https://example.com/image/${darkId}/${type}" media="(prefers-color-scheme: dark)" type="${type}" />`)}
${types.map(type => `<source srcset="https://example.com/image/${lightId}/${type}" type="${type}" />`)}
<img alt="Description of image" loading=lazy sizes=auto />
</picture>`
} I'd rather flip the question. Why should Right now it seems like it adds to the burden of authors, while not serving any obvious purpose? |
Thanks, that seems reasonable. The original motivation to require
https://www.12gobiking.nl/winkel has
I don't see this image in Google image search nor Bing image search. |
The issue I filed for #9181 was resolved and I can file another issue given a clear description. Is the suspicion that |
My suspicion is that it's entirely unsupported, but |
What is the issue with the HTML Standard?
In #9181 the
src
attribute was made optional if thesrcset
attribute is present.However, it is possible to provide the source set through previous sibling
<source>
elements. When it is, it is not clear why eithersrc
orsrcset
must be provided on the<img>
element.Omitting
src
andsrcset
works fine in practice when the source set is provided through<source>
elements, except for the complete getter steps returning early.Could we update the complete getter steps and make both
src
andsrcset
optional in these cases?The text was updated successfully, but these errors were encountered: