Does specifying image size in CSS allow the browser to do layout before download is complete?

Posted by eaolson on Stack Overflow See other posts from Stack Overflow or by eaolson
Published on 2010-03-27T19:58:19Z Indexed on 2010/03/27 20:03 UTC
Read the original article Hit count: 131

Filed under:
|
|
|

I've always tried to specify the height and width attributes for img tags in HTML. Not for style reasons, but because the browser then expects the size of the image and can do page layout even before the image has finished downloading. From the HTML spec:

The height and width attributes give user agents an idea of the size of an image or object so that they may reserve space for it and continue rendering the document while waiting for the image data.

I don't know why this has never occurred to me, but does specifying height and width in CSS, rather than inside the img tag, do the same thing?

© Stack Overflow or respective owner

Related posts about html

Related posts about img