Forum Moderators: open
Now I wonder about “width” and “height” and their purpose and necessity.
Thanks
When you specify the actual size I believe it may slightly speed up the rendering of the page because the browser won't have to determine what it is.
When you specify the actual size I believe it may slightly speed up the rendering of the page because the browser won't have to determine what it is.
...and if the browser knows the size of the image (the space it will take up on the page) before having to start downloading it then your page won't jig-around when the sizes do become known - although this will depend on your layout, and is perhaps not quite so noticeable on a fast connection.
So you say, no size by default should be way to go?
I think my Dreamweaver puts size by default, but not always though. I wonder why?
Thanks for input.
what happens is the person hotlinking will have the imge cached locally, they'll see the original image on their site. Unbeknown to them its been replaced but will look fine because they are still looking at original image in their page. If they have not specified a width and height the image will display at its native size, for example the gif I mentioned will cause a huge scroll bar to the right. If it's liquid layout it becomes even worse for them because a single paragrph many sentences long will now stretch way past the point of what is viewable without scrolling... quite evil isn't it. :)
For a default I use the image size but itsnopt all that important. Whether you use no image size or the correct image size is only going to affect the rendering speed in the browser and as mentioned by the other poster it may even be imperceptible if you have fast machine.
So you say, no size by default should be way to go?
This can't be said unless we know that DTD you use, because it may depend on the Document Type Definition whether these attributes may be mandatory or not.
In most DTDs that I know, it seems to be not mandatory, although recommended.
So look at the specs and code your pages accordingly. And then run your pages through a validator: [validator.w3.org...]
Kind regards,
R.
[edited by: Romeo at 2:35 pm (utc) on April 29, 2008]
This can't be said unless we know that DTD you use, because it may depend on the Document Type Definition whether these attributes may be mandatory or not.
AFAIK the width and height attributes of the img element are not required under any DTD. IMHO the specs [w3.org] don't necessarily state they are recommended either.
width = length [CN]
Image and object width override.
height = length [CN]
Image and object height override.When specified, the width and height attributes tell user agents to override the natural image or object size in favor of these values.
:
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.
The width and height could be specified in the CSS instead.