Image size

F

Frank

I notice that both of these work in my IE5.5

<img src="test.jpg" alt="test picture">
<img src="test.jpg" width=50 height=100 alt="test picture">

Which is the correct one to use and why?
 
D

David Dorward

Frank said:
I notice that both of these work in my IE5.5

<img src="test.jpg" alt="test picture">
<img src="test.jpg" width=50 height=100 alt="test picture">

Which is the correct one to use and why?

If you specify the dimensions (real dimensions, not an attempt to scale),
the browser can put aside space for it before it loads. Without that
information the content gets shifted around when it finds out the
dimensions by examining the image.
 
S

Sid Ismail

: I notice that both of these work in my IE5.5
:
: <img src="test.jpg" alt="test picture">
: <img src="test.jpg" width=50 height=100 alt="test picture">
:
: Which is the correct one to use and why?
:


The second way. Puts a place-marker on (recommended by web standards) for
faster browser viewing.

Sid
 
B

Barry Pearson

Frank said:
I notice that both of these work in my IE5.5

<img src="test.jpg" alt="test picture">
<img src="test.jpg" width=50 height=100 alt="test picture">

Which is the correct one to use and why?

To add to what others have already said: the 2nd one. Because if the user
doesn't actually download the image for some reason, the browser will still
leave the "right" space for it, with the "alt" text in, and so preserve the
overall layout. (But - I understand that future standards such as XHTML will
expect width="50" height="100"? I guess the ""s are optional at the moment?)
 
D

David Dorward

Barry said:
(But - I understand that future standards
such as XHTML will expect width="50" height="100"? I guess the ""s are
optional at the moment?)

XHTML 1.0 and 1.1 are current standards. As they are XML based rather then
SGML based most of the exceptions to various rules are gone.

e.g.:

SGML (HTML): Attribute values must be quoted unless the value contains only
letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods
(ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII
decimal 58) in which case the quotes are optional.

XML (XHTML): Attribute values must be quoted.

Its quite a bit easier to remember. The other changes:
<http://www.w3.org/TR/xhtml1/#diffs>
 
J

Jukka K. Korpela

Frank said:
<img src="test.jpg" alt="test picture">
<img src="test.jpg" width=50 height=100 alt="test picture">

Which is the correct one to use and why?

Both are correct. Which is better really depends. For the specific case, the
latter, since the alt text is short as compared with the width and height of
the image. If the alt text is long, then some popular browsers, when used in
no-images mode, brutally truncate it to make it fit into to size specified.
A little more on this: http://www.cs.tut.fi/~jkorpela/html/alt.html#dim

Naturally, the image should have the actual size specified by the width and
height attributes, _or_ you should have full understanding and acceptance of
the potentially crappy results of image scaling by browsers.
 
K

Kris

Jukka K. Korpela said:
Naturally, the image should have the actual size specified by the width and
height attributes, _or_ you should have full understanding and acceptance of
the potentially crappy results of image scaling by browsers.

Which makes IE/Win's behaviour of displaying ALT text in a tooltip not
so bad after all. Of course it is a fix to the wrong problem, if it is
an intended fix in the first place.
 
S

Steve R.

David Dorward wrote in message ...
If you specify the dimensions (real dimensions, not an attempt to scale),
the browser can put aside space for it before it loads. Without that
information the content gets shifted around when it finds out the
dimensions by examining the image.

Here's an example I've just viewed, where the image size isn't specified. It's quite noticeable on
dial-up how the image boxes shift around before they eventually fill.

http://www.amykimber.com/photos/cat.asp?al=1&sub=1&thumb=true
 

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

Forum statistics

Threads
474,094
Messages
2,570,615
Members
47,231
Latest member
Satyam

Latest Threads

Top