473,785 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6862
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******** *************@n ews.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.infosystem s.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.infosystem s.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
2234
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 specified. What is the value of an unspecified HEIGHT or WIDTH attribute. How do I dynamically set the attribute to unspecified, after having previously used the <IMG> with explicit HEIGHT and WIDTH attributes? - David
7
2981
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
1124
by: DM | last post by:
For <img> tags, are the width and height attributes necessary? Could they just be omitted? dm
4
5622
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 has 2 columns. The size of the first one has 2/3 of the panel.width and the size of the second one has 1/3 of the panel.width. The only way I got to calculate these values was: private void MakeCentralTable(Panel panel)
1
2373
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 the image height and width to store? Thanks in advance. Blake Verisga
2
6770
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 set image width. This problem makes my link clickable only on its borders. When viewing HTML source I could see that spacer.gif has no width and height, so HTML shows only 1px x 1 px image.
4
1692
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 copies of the files. There are various scripting and "active" technologies enabled on the server: ASP.NET ASP Front Page Extensions Perl
3
5315
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 (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
7
9865
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 W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"really valid?
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.