Home > Bookmarks, Html, Wordpress > max-width for images in IE

max-width for images in IE

November 8th, 2007 Leave a comment Go to comments

To use max-width the syntax is:

selector {max-width:value;}

Internet Explorer up to version 6 doesn’t support the max-width property but has the ability to perform javascript like functions on it’s CSS so you can fake max-width with it. Here’s the syntax:

selector {width: expression(this.width > value ? value: true);}

example for IMG html tag:

img {
max-width:390px;
/* IE Image max-width */
width: expression(this.width > 390 ? 390: true);
}

NOTE: max-width property does NOTHING for the file size if used with an image.

  1. July 21st, 2009 at 07:58 | #1

    Finally an example that works, Cheers.

  2. June 17th, 2009 at 22:29 | #2

    thanks, works perfectly.

  3. November 20th, 2008 at 21:10 | #3

    great!

  4. daflyguy
    August 21st, 2008 at 12:27 | #4

    thanks, I’ve been searching for a straight forward method and this works perfectly.

  5. Chris
    August 10th, 2008 at 10:29 | #5

    Yay! Thanks.

  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.154204 sec (gzip)