Specify the size of an image

J

Jsp

If you want an image to appear in its original size, is there any reason
for defining the <width> and <height> within the <img> tag, or in its
class or id in the CSS?
Can it show wrong in some browser if you simply leave out the size
specification?

Thanks,
Jsp
 
J

Jukka K. Korpela

Jsp said:
If you want an image to appear in its original size,

And why would you want anything else, in HTML? (Leaving scaling to browsers
is usually the worst imagineable alternative.)
is there any reason
for defining the <width> and <height> within the <img> tag,

You mean width and height _attributes_ - referring to them with
<width> and <height> is odd.

The reason for using those attributes is that they may speed up rendering,
since the browser can reserve space for the image before getting the actual
data. Those attributes are however best omitted if the image is small as
compared with the alt text, since most current browsers (counted by
frequency of use) by default truncate the alt text into the length that
fits in into the space allocated for the image.
or in its
class or id in the CSS?

That's a different issue. Use those attributes if you have some specific
need for them, like styling a particular image.
Can it show wrong in some browser if you simply leave out the size
specification?

No.
 
S

Simon

Hello,
If you want an image to appear in its original size, is there any reason
for defining the <width> and <height> within the <img> tag, or in its
class or id in the CSS?

Yes. Specifying the height and width allows the browser to display the
text correctly on the page while downloading the image. If the browser
doesn't know how much space to leave on the screen for the image, you
have that annoy effect where the text is moved all around the screen
while the images are downloaded.
Can it show wrong in some browser if you simply leave out the size
specification?

Not that I'm aware of.

Regards
Simon
Custom Net Hosting
http://www.customnethosting.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top