Re: CSS vs. img size attributes

On Tue, 25 Nov 2014 09:34:35 +0100, Henrik Andersson  
<henke@henke37.cjb.net> wrote:

> Is there a clear specification that rules on which takes precedence, CSS
> or explicit width and height attributes of an <img> element in a HTML
> document?

https://html.spec.whatwg.org/multipage/rendering.html#attributes-for-embedded-content-and-images
->
https://html.spec.whatwg.org/multipage/rendering.html#maps-to-the-dimension-property
->
https://html.spec.whatwg.org/multipage/rendering.html#presentational-hints

Your CSS rules using width and height properties win over <img width  
height> presentational hints.

> The same goes for any replaced element: what if the replacing content
> has a set size in the DOM? Or for that matter, if it has an intrinsic  
> size.

http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-width
http://www.w3.org/TR/CSS21/visudet.html#inline-replaced-height

-- 
Simon Pieters
Opera Software

Received on Tuesday, 25 November 2014 10:44:58 UTC