hello.
I was wondering why exactly you should declare the height and width of an image. I'm doing it but have no idea why...
I've read (what seems like!) loads of stuff and it's not mentioned as far as I can see.
thanks
larmyia
<img> width and height declaration
As fas as I know, the page won't validate without the width and height attribute.
I think it may be to do with broken images still displaying the right sized placeholders, although even if you don't specify a width and height, it shows it the same.
Interesting point, I'd like to hear other responses.
<img> width and height declaration
The height and width attributes should be included to speed up the page a little. The browser has a smidgen less work to do when you feed it the dimensions of your image. If you don't provide these dimensions, the browser needs to examine the image in greater depth to determine these dimensions before rendering the document.
<img> width and height declaration
Back in the "old days" before broadband you used to have to wait for the images to load. If the web page didn't have the images height and width from the <img> tag the browser would assume a very small size for the image and only allocate a tiny square. Once the image finally loaded it would pop into place and would then throw off the content on the rest of the page since it was no longer a tiny little square of unknown dimensions. Height and width declarations were essential then so that the browser would reserve the right amount of space for all the images while they took hours to load.
Nowadays the browsers are smarter and they load the images height and width before the image itself actually loads. (They know the images size before it loads.) So they leave the right amount of room. Connections are much faster too, so most pages will load all at once, images included, with broadband connections.
<img> width and height declaration
ahhhh, now that all makes much more sense! I hate writing code that I don't understand
ta very much
larmyia
<img> width and height declaration
Back in the "old days" before broadband
Not just in the old days - even today I see sites(image heavy sites like fora) where you have to wait till it´s completely rendered before you can start to read - because the text is jumping around all the time...
Also, providing the image dimensions means that your site layout won´t break just because the image isn´t available.