Re: [CSS Image Sizing] Sizing with Alt Text

On 7/11/13 9:32 AM, Sudarshan wrote:
> On different browsers this content is rendered differently. Firefox
> seems NOT to apply the sizing algorithm as specified CSS spec when alt
> text is used, where as Chrome seems to apply it.
> Is there a *correct* behavior as per the spec?

Yes.  The relevant spec is 
http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#images-0 
which says:

   When an img element represents some text and the user agent does not
   expect this to change, the element is expected to be treated as a
   non-replaced phrasing element whose content is the text, optionally
   with an icon indicating that an image is missing, so that the user
   can request the image be displayed or investigate why it is not
   rendering. In non-graphical contexts, such an icon should be omitted.

The "represents" concept is defined at 
http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#the-img-element 
but unfortunately is not directly linkable.  Search for "represents 
depends".  The testcase you provide falls into this branch:

   Otherwise
     The element represents the text given by the alt attribute.

> I have read the parts
> http://www.w3.org/TR/css3-images/#sizing
> http://www.w3.org/TR/CSS21/conform.html#replaced-element
> and did not find any conclusive answers

In this particular case <img> is not a replaced element per HTML spec. 
It's just rendered based on its computed display, just like <span> would 
be, for example.  This is what Firefox implements, hence the behavior 
you observe there.

-Boris

Received on Thursday, 11 July 2013 14:50:47 UTC