Log in

View Full Version : What's best practice when placing an image within a page - dimentions or not?



Burgin
06-17-2010, 02:34 PM
I've notice that some coders when pacing an image on a page use...

<img src="assets/images/image.png">

and others use...

<img src="assets/images/image.png" width="200px" height="100px">

Both apper to display the image the same but what's the benefits of the dimensions?

Beverleyh
06-17-2010, 06:43 PM
So the browser can allocate the space in advance of image download.

We don't notice the effect so much now with fast broadband speeds but dialups see the page chucking text around as images push themselves into place when dimensions arnt set, which is very distracting and confusing.

When dimension are there the browser allocates placeholders for the images to download at their leisure and text appears in the correct place from the start. Its better practise to include them.