473,237 Members | 1,155 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,237 software developers and data experts.

img height="" width="" - undefined?

Dear Experts,

It looks as if the HTML4 spec does not define a meaning for empty height
and width attributes in an IMG element. Moz seems to ignore them, while
IE7 sets the dimension to 1 pixel (or something like that).

I have a vague recollection that "" did have a defined meaning at some
point in the past, but maybe I am mis-remembering. Can anyone confirm?

I have encountered this in some third-party PHP code that I'm using on
my web site, which seems to not work for an IE7 user.
Regards, Phil.
Nov 26 '07 #1
3 5282
Phil Endecott:
It looks as if the HTML4 spec does not define a meaning for empty height
and width attributes in an IMG element. Moz seems to ignore them, while
IE7 sets the dimension to 1 pixel (or something like that).
An empty height or width attribute is an error because height and
width, if specified, must have a length (either a pixel value or a
percentage). The HTML4.01 specification doesn't say how user-agents
should handle errors, but I think ignoring the empty value is
reasonable error recovery.

With error recovery like that, small wonder MS Explorer crashed.

--
Jock
Nov 26 '07 #2
On 11/26/2007 4:42 AM, Phil Endecott wrote:
Dear Experts,

It looks as if the HTML4 spec does not define a meaning for empty height
and width attributes in an IMG element. Moz seems to ignore them, while
IE7 sets the dimension to 1 pixel (or something like that).

I have a vague recollection that "" did have a defined meaning at some
point in the past, but maybe I am mis-remembering. Can anyone confirm?

I have encountered this in some third-party PHP code that I'm using on
my web site, which seems to not work for an IE7 user.
Regards, Phil.
While the height and width attributes are recommended, they may be
omitted. I think omitting them would be better than leaving empty sizes.

The reason that these attributes are recommended is that they speed up
the rendering of a Web page. Browsers generally use these attributes to
allocate space for the image on the rendered page before the image
itself is available from the server. Without the attributes, some kind
of default space is allocated because the image's size is still unknown.
Then, when the image is available, the page must be re-rendered for the
actual size of the image.

With dynamically generated pages, however, even the image itself might
not yet known when the page starts to render. Thus, its size cannot be
predetermined for the height and width attributes.

--
David E. Ross
<http://www.rossde.com/>

Natural foods can be harmful: Look at all the
people who die of natural causes.
Nov 26 '07 #3
In our last episode, <Oa****************@newsfe4-win.ntli.net>, the lovely
and talented Phil Endecott broadcast on comp.infosystems.www.authoring.html:
Dear Experts,
It looks as if the HTML4 spec does not define a meaning for empty height
and width attributes in an IMG element. Moz seems to ignore them, while
IE7 sets the dimension to 1 pixel (or something like that).
I have a vague recollection that "" did have a defined meaning at some
point in the past, but maybe I am mis-remembering. Can anyone confirm?
I believe you are misremembering or confusing something. Possibly you are
thinking of the ALT attribute. For that, an empty value is recommended for
purely decorative images (e.g. scroll work). This can be interpreted by the
user agent so as to avoid junking up a text screen with some default ALT
text it might otherwise include if this required attribute were missing.
I'm not too crazy about the example in the spec. It (correctly) suggests
that if an image is purely decorative, ALT="" should be prefered to ALT="red
ball". However, if you use the image to mean "Don't", "Bad Example", or
"Stop", those should be the value of ALT.

However, I do not recall and cannot of think of an reasonable use for an
empty height or width attribute. These are not required attributes, and
they default to the natural size of the object. But not supplying an
optional attribute and supplying it with an empty value are two different
things. An empty value has to be an error, and what various user agents do,
if anything, to attempt to recover from this error is likely to vary from
agent to agent.

From the Bad Idea Hall of Fame are various schemes for pre-caching images.
Most such schemes used at least 1x1 for the 'hidden' images, but perhaps you
read some guy's plan to use empty dimensions for this purpose. I think I
have hinted 'precaching' is a really Bad Idea, and probably wouldn't work
this way anyway.
I have encountered this in some third-party PHP code that I'm using on
my web site, which seems to not work for an IE7 user.
It's an error. It cannot be expected that different browsers will each
handle it the same way.

--
Lars Eighner <http://larseighner.com/us****@larseighner.com
Countdown: 420 days to go.
Nov 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Torbjørn Pettersen | last post by:
I've got a table where I want some of the cells to use a background image. The cells have variable height, so I am using an image with a rather small height to fill up the background of the cells,...
2
by: Georg Goerg | last post by:
hello, i want to make website with a top navigation bar and one on the left. so by using css i define three layers and everyone of them has length attr. in percents. but if i want to put...
15
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width:...
2
by: Thomas Wang | last post by:
I draw a combobox on a form, but I can not change its height, What I can do about it? B.Rgds
3
by: Lasse Edsvik | last post by:
Hello I was wondering if its possible to the "width" and "height" of a text when creating a pic from text. string sometext = "bla bla"; Font font = new Font("Verdana", 18); SolidBrush sb =...
2
by: Brian Bischof | last post by:
To get my formatting to work with Firefox and IE browsers, I have to be very careful about the layout. So I'm removing all the Style tags that set the Height and Width values (and some of these...
2
by: Dag Sunde | last post by:
I have the following function to resize a div element (Content) depending on the size of another div element (leftConent). function adjustContentHeight() { var content =...
16
by: Tantale | last post by:
I used this serviec to check my webpage http://www.jmrw.com/Abroad/Barcelone/index.htm Made with Dreamweaver 8. The result is 206 errors, most of them "end tag omitted, but OMITTAG NO was...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.