[whatwg] require img dimensions to be correct?

Ian Hickson ian at hixie.ch
Fri Apr 11 00:02:20 PDT 2008

On Sun, 4 Mar 2007, Sander Tekelenburg wrote:
> Allowing percentages would be entirely presentational and thus have no 
> place in HTML.
> We struggled with this for the WRI requirements[*]. We seem to be 
> settling on requiring a width and height to be specified in HTML, 
> because as nice as CSS is, Web pages must not be CSS-dependant. Even if 
> the author means to provide CSS, it might not be available 
> (network/server error; saving and local viewing of the HTML file; User 
> CSS overrides) (A followup requirement would probably have to be that 
> when CSS is available, and specifies IMG size in px, it must be the same 
> as the size specified in the HTML.)
> The only other sensible option would be to completely disallow width and 
> height in HTML. But that will result in 'jumpy rendering' because 
> browsers can't allocate the proper rendering space until the image's 
> dimensions are known.
> [*] <http://webrepair.org/02strategy/02certification/01requirements.php> 
> Btw, this is our initial take. We very much welcome community feedback.

On Sat, 17 Mar 2007, Dean Edridge wrote:
> Firstly, the chance of someone not being able to access the CSS for a 
> web page is I'm guessing, pretty slim.
> The chance of someone not being able to access this CSS, *and* actually 
> noticing or caring that the images aren't rendered correctly (if in fact 
> they aren't), is very very slim. So I don't think it's really worth 
> throwing away the benefits of CSS just for a very rare occasion like 
> this that would probably not be of benefit to anyone anyway.
> Secondly, when scaling images you would normally just set the height, 
> not the width. This ensures that the images proportions are kept intact, 
> as specifying a width distorts the image.
> This being said I hope no one makes it a requirement to specify just the 
> in-line height, as this would still create problems. For example if you 
> had an images height set within the html to 100% of the parent elements 
> height, and there was no CSS available to specify the parents height 
> (for example a div), the user agent would probably just stretch the 
> image to the full height of the screen (FF doesn't do this, but IE and 
> Opera do), therefore causing more problems than if you had just left all 
> the styling in the CSS to begin with. So the long and the short of it 
> IMO is to just use CSS and rely on the user-agent to show the page the 
> best it can in the absence of CSS.

On Fri, 16 Mar 2007, Benjamin West wrote:
> <img style="height: 50px; width: 50px;" /> Why is accessing CSS a 
> problem?

On Fri, 16 Mar 2007, Gareth Hay wrote:
> If i'm not mistaken, the idea of separation of content and style means 
> you can use your own css, or even none at all, and still have the 
> ability to view the content.
> If a page is dependent on the css, then, although in a separate file, it 
> is fundamentally not separate at all, and we might as well just shove 
> the css into the same html file anyway.

On Sat, 17 Mar 2007, Dean Edridge wrote:
> I never proposed that a web page should be dependant on CSS, nor did I 
> say that there shouldn't be a separation of content and style. Quite the 
> opposite. I said that if there is no CSS available for an <img> tag, the 
> browser should just display the image the best it can(and they do this 
> quite well already, in my experience). And that this very rare occasion 
> of CSS failure does not warrant the mandatory requirement of in-line 
> styling of the <img> tag.

On Tue, 20 Mar 2007, Gareth Hay wrote:
> [...] users may choose to apply their own css (even if this is not 
> widespread in use), or even disable css altogether.
> I don't doubt you do some elaborate and cool things with inline styles, 
> I have been known to use them myself, but it is my understanding that 
> conceptually, HTML is for content markup and CSS for styling that 
> markuped content. Maybe someone can correct me on this, if I am 
> incorrect.

On Sat, 17 Mar 2007, Dean Edridge wrote:
> I never said that accessing the CSS would be a problem. It was suggested 
> earlier that in case it was, we should make it compulsory to set the 
> width and height of images in-line. If you read my post it explains the 
> problems of having a mix of in-line styling and styles in a CSS file, 
> and suggests that styling should just be left in the CSS and not a mix 
> of both. This is because, if there is no CSS available, the browser only 
> has styling rules for some of the elements and this can sometimes be a 
> problem.

On Sat, 17 Mar 2007, Sander Tekelenburg wrote:
> The argument is not rendering "correctly", but to avoid "jumpy" 
> rendering/achieve faster page loading by letting the browser know 
> beforehand what amount of space to allocate for the image.
> I don't see how this throws away CSS benefits. Quite the contrary, as it 
> disallows specifying width and height in percentages[*] through HTML. 
> I'd prefer to say that defining width and height in HTML would be 
> illegal, as it is presentational and should therefore be done through 
> Style Sheets. The only problem then is that, when CSS is not available, 
> the UA won't know what amount of space to allocate to the image until it 
> is completely fetched. It's a (mild) case of CSS-dependancy. The only 
> way I see to avoid that is to specify a width and height in HTML. And 
> we're talking about pixels only[*], not percentages which would be 
> purely presentational and thus should be done through Style Sheets.
> Maybe the requirement should in fact be that the image's *actual* width 
> and height be specifed through HTML.
> Btw, remember that the target for the WRI's requirements are "Automated 
> Web Publishing Systems". It can't be hard for an authoring system to 
> ensure that the width and height for a particular image is set the same 
> both in HTMl and CSS. And note that this synchronicity is only required 
> when the image's height and width is specified in px[1] -- scaling 
> through %/em/ex, a CSS benefit, is specifically allowed.
> [1] I see it didn't clearly say so at 
> <http://webrepair.org/02strategy/02certification/01requirements.php#req24>. 
> It does now.

On Sat, 17 Mar 2007, Andrew Fedoniouk wrote:
> So the main motivation is to avoid "jumpy" rendering, correct?
> In principle style sheet downloading is also asynchronous process. And 
> CSS can do many things that may cause "jumps". So if we will require 
> image to have known dimensions up front then this means that CSS has to 
> be loaded before any initial rendering.
> I mean that <img width=... height=...> is only one piece of the puzzle.
> I think that in most cases will be better if we could package complex 
> pages into zip envelopes and deliver them in the whole. That would be 
> real solution of "jumps".  And <img width=... height=...> is a 
> palliative.

On Sun, 18 Mar 2007, Sander Tekelenburg wrote:
> > I think that in most cases will be better if we could package complex 
> > pages into zip envelopes and deliver them in the whole.
> Maybe. But then you'd need sophisticated content-negotiation, or 
> otherwise you'd force data to be downloaded by UAs that can't or won't 
> handle it. (I don't mean the zip file itself, but its content.)

On Sun, 18 Mar 2007, Alexey Feldgendler wrote:
> Such a technology exists: MHTML. However, it's a waste of traffic to 
> include repeated images with every page served.

Taking all the above into account, I'm not sure that there is really a 
strong argument to change the spec (which allows dimensions to be 
specified, but not percentages). So I have left the spec as is for now.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list