- Notifications
You must be signed in to change notification settings - Fork2.9k
Description
https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element currently requires:
The
src
attribute must be present, and must contain avalid non-empty URL potentially surrounded by spaces referencing a non-interactive, optionally animated, image resource that is neither paged nor scripted.
and
The
srcset
attribute may also be present, and is asrcset attribute.
In other words, a validator should complain about animg
element with asrcset
attribute but nosrc
, andhttps://validator.nu/ does.
However, it's not clear why it's important to require putting one source in thesrc
attribute, instead of putting them all insrcset
. The processing model deals withsrc
being missing:
- Inupdate the source set,default source will remain the empty string
- Increate a source set, ifdefault source is the empty string, obviously there's nothing to add tosource set
In other words, omittingsrc
works just fine in practice.
Whensrcset
was new it made sense to require asrc
, but nowsrcset
has been supported everywhere for many years:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/srcset#browser_compatibility
Is it time to makesrc
optional and not require sending unused markup like this?