473,797 Members | 3,204 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resetting default <IMG> HEIGHT and WIDTH attributes

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

Jul 20 '05 #1
2 2234
David D. wrote:
If an <IMG> specifies a WIDTH but not a HEIGHT, then height is internally
determined so as to maintain the image's aspect ratio.
By reading the file itself.
Aspect ratio is also preserved if HEIGHT but not WIDTH is specified.

What is the value of an unspecified HEIGHT or WIDTH attribute.
Its undefined and the browser reads the image file to get its width
and/or height.
How do I dynamically set the attribute to unspecified, after
having previously used the <IMG> with explicit HEIGHT and WIDTH
attributes?


Simply put, you don't reliably do it. What exactly are you trying to do
though? Sounds like you are trying to make a thumbnail page where the
images swap out by resizing them??
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/
Jul 20 '05 #2
Fox


"David D." wrote:

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?
WIDTH="100%" HEIGHT="100%"

- David

Jul 20 '05 #3

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

Similar topics

5
2856
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and probably a couple of other IE and NS versions I can't get to right now) don't want to play nice unless I hard code the image height. (Yes, I'm one of those who insists on still coding for NS4.)
9
72125
by: Wladimir Borsov | last post by:
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like <IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to...
5
12311
by: homecurr | last post by:
I am writing a tool to generate html and have a problem with the <img> tag. The tool generates something like "<img src="...">". At the time the html is generated, the tool does not know the actual image size, but I do want to resize any image so that their width and height will both be smaller than 100. I also want to keep the iamge width/height ration so the image looks "normal". If I use <img src="..." width=100 height=100> the image...
15
122167
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: 123px; height: 456px;" alt="">
4
2594
by: Jim Moe | last post by:
Hello, Mozilla (suite and Firefox) ignore the height and width attributes of <img> when the image itself is unavailable (404); only enough space is allocated for the alt text. Is this expected behavior for Standards mode? -- jmm dash list (at) sohnen-moe (dot) com (Remove .AXSPAMGN for email)
10
3321
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to capture the width or height. Once I can do that I can manipulate them. Here is the HTML for the <img> <div class="ImgMnp" id="myImg" onmouseover="imgSize('myImg','fpImg)"> <img src="images/FirePlace.jpg" width="480" height="640" id="fpImg" />
1
4628
by: Carl | last post by:
Hi all I have a javascript function that drags and drops an element (ie img) into a container (ie bordered div). The function works and returns the element and and container. My next step is to center the element in the container if the user is sloppy with positioning it. I can only test this on IE6 and IE5.5 and it fails. It positions the element too much right and low. Here is the function: function SnapToContainer(Container,El) {
4
1987
by: bgold12 | last post by:
Hey, I've come across a strange behaviour that shows itself in IE 7.0 and Firefox 3 and probably other browsers. In the code below, which is a complete HTML document which validates as XHTML 1.0 Strict, I display an image named Images/DivLine1.jpg (which is a simple 1x5 pixel blue line) inside two divs across 100% of their width, the first of which has 50px height and the second of which has 100px height. In both cases, I set the image...
0
9537
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
10246
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10209
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
10023
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
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6803
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
5459
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...
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.