Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -31252,8 +31252,13 @@ interface <dfn interface>HTMLImageElement</dfn> : <span>HTMLElement</span> {
<p>The requirements on the <code data-x="attr-img-alt">alt</code> attribute's value are described
<a href="#alt">in a separate section</a>.</p>

<p>At least one of the <code data-x="attr-img-src">src</code> and <code
data-x="attr-img-srcset">srcset</code> attributes must be present.</p>
<p>If the <code>img</code> element's parent is not a <code>picture</code> element,
then at least one of the <code data-x="attr-img-src">src</code> and
<code data-x="attr-img-srcset">srcset</code> attributes must be present.</p>

<p>If the <code data-x="attr-itemprop">itemprop</code> attribute is specified on the
<code>img</code> element, then the <code data-x="attr-img-src">src</code> attribute must also be
specified.</p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an img element is not a child of a picture element, aren't the src or srcset attributes required on that img element?
Therefore, simply deleting this sentence is not appropriate.

@johannesodland johannesodland Jun 28, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to add this, but I was looking to the video and audio elements and could not find a similar requirement. If the img element is a child of a picture element, do we need to validate the source elements?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the text to depend on whether or not the parent element is a picture element:

If the img element's parent is not a picture element, then at least one of the src and srcset attributes must be present.

Do you think that is sufficient?

It is still very much possible to have markup like this:

<picture>
  <img alt="some alt text">
</picture>

If we additionally require a source element, then its still possible to write markup like this:

<picture>
  <source media="print" srcset="">
  <img alt="some alt text">
</picture>

<p>If the <code data-x="attr-img-src">src</code> attribute is present, it must contain a
<span>valid non-empty URL potentially surrounded by spaces</span> referencing a non-interactive,
Expand Down