473,386 Members | 1,674 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,386 software developers and data experts.

img tag width, height attributes necessary?

DM
For <img> tags, are the width and height attributes necessary? Could they just
be omitted?

dm
Jul 21 '05 #1
7 6823
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary? Could
they just be omitted?


They are not required but I recommend their use.

Without this information in the HTML, the UA cannot account for the
viewport space needed for the image. As a result, it happens that if the
user is reading below the image, suddenly the UA discovers the dimensions
and the whole page jumps disconcertingly.

And it's important to be sure the values of height and width are the exact
pixel dimension of the image being used. Don't resize images in the
browser, it leads to either a heftier download than is needed (when HTML
reduces size) or a pixellated ugly image (when HTML increases size).
Jul 21 '05 #2
On Thu, 04 Nov 2004 13:28:12 -0500, Neal <ne*****@yahoo.com> wrote:
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary? Could
they just be omitted?


They are not required but I recommend their use.


And apologies for the crosspost - followups are now set to ciwah.
Jul 21 '05 #3
DM
Neal wrote:
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary? Could
they just be omitted?

They are not required but I recommend their use.

Without this information in the HTML, the UA cannot account for the
viewport space needed for the image. As a result, it happens that if the
user is reading below the image, suddenly the UA discovers the
dimensions and the whole page jumps disconcertingly.

And it's important to be sure the values of height and width are the
exact pixel dimension of the image being used. Don't resize images in
the browser, it leads to either a heftier download than is needed (when
HTML reduces size) or a pixellated ugly image (when HTML increases size).


Thanks for the reply. On a related question, if you do provide width and height
attributes, does it matter whether you use <img> tag or CSS attributes?
Jul 21 '05 #4
On Thu, 04 Nov 2004 10:32:14 -0800, DM <elektrophyte-yahoo> wrote:
Thanks for the reply. On a related question, if you do provide width and
height attributes, does it matter whether you use <img> tag or CSS
attributes?


If you provide the height and width in content, the CSS values are not
necessary. Remember that a page can be loaded with images and without CSS.
Whenever the image is part of the HTML, the height and width should be in
the HTML as well.
Jul 21 '05 #5

"DM" <elektrophyte-yahoo> wrote in message
news:41*********************@news.cablerocket.com. ..
Neal wrote:
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary? Could
they just be omitted?

They are not required but I recommend their use.

Without this information in the HTML, the UA cannot account for the
viewport space needed for the image. As a result, it happens that if the
user is reading below the image, suddenly the UA discovers the
dimensions and the whole page jumps disconcertingly.

And it's important to be sure the values of height and width are the
exact pixel dimension of the image being used. Don't resize images in
the browser, it leads to either a heftier download than is needed (when
HTML reduces size) or a pixellated ugly image (when HTML increases

size).
Thanks for the reply. On a related question, if you do provide width and height attributes, does it matter whether you use <img> tag or CSS attributes?


You should do it in the HTML. The height and width of an image are actual
attributes of the image, they're not presentational suggestions. And then
there's no need to do it in the CSS.

Jul 21 '05 #6
*Neal* <ne*****@yahoo.com>:
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary?


They are not required but I recommend their use.


For purely decorative images, which correctly have empty 'alt' texts, they
should be omitted, though. Not all of these should or could be included
per CSS.

F'up2 comp.infosystems.www.authoring.html

--
Useless Fact #4:
Coca Cola was originally green.
Jul 21 '05 #7
*Neal* <ne*****@yahoo.com>:
On Thu, 04 Nov 2004 10:07:31 -0800, DM <elektrophyte-yahoo> wrote:
For <img> tags, are the width and height attributes necessary?


They are not required but I recommend their use.


For purely decorative images, which correctly have empty 'alt' texts, they
should be omitted, though. Not all of these should or could be included
per CSS.

F'up2 comp.infosystems.www.authoring.html

--
Useless Fact #9:
Percentage of Africa that is wilderness: ca. 28%.
Percentage of North America that is wilderness: ca. 38%.
Jul 21 '05 #8

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

Similar topics

2
by: David D. | last post by:
If an <IMG> specifies a WIDTH but not a HEIGHT, then height is internally determined so as to maintain the image's aspect ratio. Aspect ratio is also preserved if HEIGHT but not WIDTH is...
7
by: Ana | last post by:
I just ran a report on a site I'm redesigning and came up with all these missing height/width tags. How important are they? Should I go through the trouble of making sure they're there? Ana
15
by: DM | last post by:
For <img> tags, are the width and height attributes necessary? Could they just be omitted? dm
4
by: xiko tripa | last post by:
Hi. I have an apsx page with a Panel inside. The panel has his properties Width and Height set to 590 and 390 respectively. I call a function to make up an table inside this panel. That table...
1
by: Blake Versiga | last post by:
After pulling an image from the data base and the Image.Height and Image.Width are not set to the ImageURL's attributes. 1) Is there a way to have these properties updated? or 2) How do I get...
2
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not...
4
by: Dotcom | last post by:
I have an ASP.NET application that is mysteriously acquiring height and width attributes on a particular IMG element on multiple pages. This is not being caused by someone editing or uploading new...
3
by: Phil Endecott | last post by:
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...
7
by: Christian Hackl | last post by:
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.