New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 5 users

Issue metadata

Status: Assigned
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Sign in to add a comment

Issue 671871: Handling of <img> tags with no src attribute doesn't follow the HTML spec

Reported by, Dec 7 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:53.0) Gecko/20100101 Firefox/53.0

Example URL:

Steps to reproduce the problem:
1. Load the attached testcase.

What is the expected behavior?
No red.

What went wrong?
There is red.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: 56.0.2924.18 (Official Build) dev (64-bit)  Channel: n/a
OS Version: OS X 10.10
Flash Version: 

See for the spec references.
119 bytes View Download

Comment 1 by, Dec 7 2016

Labels: M-57 OS-Linux OS-Windows
Status: Untriaged (was: Unconfirmed)
Tested the issue on chrome Stable #55.0.2883.75, Canary 57.0.2943.0 & Dev #56.0.2924.18 in Mac 10.11.6 and was able to reproduce the issue.

This is a Non-Regression issue since seeing this from M30 #30.0.1549.0, Making the status to Untriaged so that the issue would get addressed.

Note : Able to reproduce the issue in windows 10.0 and Linux Ubuntu 14.04.

Thank you.

Comment 2 by, Dec 7 2016

Tested the issue on Chrome 54.0.2840.85 on Android 4.4.2 and was able to reproduce there, also.

Comment 3 by, Dec 7 2016

Components: -Blink Blink>Image

Comment 4 by, Dec 7 2016

Status: Assigned (was: Untriaged)
Relevant comment from bugzilla:
For the record, I'll quote the spec text that supports what we're doing here. (since I just had a reason to find it, & it'll be easier for me to find again it in the future if I paste/link it here)

Firstly, the spec says this sort of <img> "represents nothing":
>  --> If the src attribute is not set and either the alt attribute
>      is set to the empty string or the alt attribute is not set at all
>          The element represents nothing.

And later in the rendering section, it explains what that means for rendering:
>  --> If the element is an img element that represents nothing and
>      the user agent does not expect this to change
>          The user agent is expected to treat the element as an empty
>          inline element.

So, we treat it as if it were an empty <span>, basically (as the spec requires).

Comment 5 by, Dec 7 2016

Note that the spec text seems to imply that a will-change of some kind might change the behavior.

Comment 6 by, Dec 7 2016

Labels: -OS-Linux -OS-Windows -OS-Mac -M-57 OS-All

Comment 7 by, Dec 7 2016

> a will-change of some kind might change the behavior.

I think this only applies if an image isn't yet available, but expected to become available (e.g. when a network request completes).
If an <img> is simply otherwise empty (e.g. source URL to be filled by js DOM changes later) there's no way for a browser to, as the spec says, "expect this to change" at parse/layout time.

Comment 8 by, Mar 29 2018

Labels: Hotlist-Interop
This creates webcompat issues for Firefox

Some developers are using img without src and expect it to work.

Comment 9 by, Mar 29 2018

Comment 10 by, Mar 29 2018

Thanks for the update. Still not sure when I'll get to it.

Comment 11 by, Apr 6 2018

We apply the second rule from the list at (the rule quoted above is the fourth rule, and hence not the "first applicable"):

> If the element does not represent an image, but the element already has intrinsic dimensions (e.g. from the dimension attributes or CSS rules), and either:
>     the user agent has reason to believe that the image will become available and be rendered in due course, or
>     the element has no alt attribute, or
>     the Document is in quirks mode
>         The user agent is expected to treat the element as a replaced element whose content is the text that the element represents, ...

(with the relevant keys being "does not represent an image" ["nothing" != "image"], "has intrinsic dimensions" and "has no alt attribute")

Comment 12 by, Apr 6 2018

But in this case there are no intrinsic dimensions.  The "CSS Rules" clause of the "intrinsic dimensions" bits means things like rules inside an SVG image.  In particular, (which is what "intrinsic dimensions" links to) clearly says:

> The width and height as defined by the element itself, not imposed by the surroundings

and the CSS rules in the document the image is embedded in are definitely surroundings.

Comment 13 by, Apr 6 2018

Put another way, that clause is meant to handle:

  <img width="100" height="100">

with no src and no alt.  Which is not the case we're looking at here.

Comment 14 by, Apr 6 2018

I guess the "CSS Rules" bit would only ever come into play when the "...has reason to believe..." condition is true then? Otherwise there wouldn't be intrinsic dimensions to take into consideration except the ones from the dimension attributes.
Anyway, this makes it fairly easy to see where the bug is in the implementation =).

Comment 15 by, Apr 6 2018

Oh, good point.  This spec is somewhat misusing the concept of "intrinsic dimensions" to start with; I filed on that.  Basically, I don't see any way you can get intrinsic dimensions here unless you are representing an image; the spec should just clearly say it's talking about the dimension attributes.

Comment 16 by, Apr 6 2018

Thanks for filing the issue, the "not representing an image" bit was indeed what made me (and possibly whoever implemented the current behavior) think something else was intended here.

Comment 17 by, Apr 6 2018


Sign in to add a comment