[whatwg] <img> element comments

Andreyka Lechev leechy at leechy.ru
Tue Nov 7 10:48:37 PST 2006


On 07.11.2006, at 19:49, Shadow2531 wrote:

> On 11/7/06, Anne van Kesteren <fora at annevankesteren.nl> wrote:
>
>> I thought the proposal was that only that (setting height and  
>> width to the
>> intrinsic size of the image) would be conforming, but that  
>> rendering would
>> still be the same.
>
> [encouraged if you need to resize the image - alt]
> <img src="276x110.png" style="width: 50%; height: 50%;" width="276"
> height="110" alt="fallback text" title="description">
>
> If that's correct, doing things the proposed, encouraged, conforming
> way seems fine as far as UAs that support css are concerned.

Don't forget that percentage values are relative values. And in  
current browser implementations, setting those values via CSS-rules  
or using width- and height-attributes are leading to different  
results! It's due to different parents to calculate actual (pixel)  
values from!


CSS values are relative to the the parent element in HTML tree:

<div style="width: 100px; height: 100px;">
	<img src="276x110.png" style="width: 50%; height: 50%;">
</div>
=> displays image 50x50px.


Attributes values are relative to the actual size of the image:

<img src="276x110.png" width="50%" height="50%">
=> displays image 138x55px.


That may be very useful in many cases, so as a HTML-coder, I don't  
think anybody should change that behavior without proposing something  
to replace it.

--
Andreyka Lechev
leechy at leechy.ru





More information about the whatwg mailing list