IE6 min-width and max-width

August 2, 2008 at 3:21 pm (CSS)

IE6 doesn’t understand few important CSS properties:  

min-width, max-width

Here is a workaround to achieve this using CSS Expressions*.

#wrapper {
   width: expression(
      (document.documentElement.clientWidth > 962)? “960px” :
         (document.documentElement.clientWidth < 762)? “760px” :
            “auto”);
}

Only max-width can be applied as given below:

width:expression(document.body.clientWidth > 800? “800px”: “auto” );

Note: This won’t work for <body> tag, IE alone recognizes the CSS expressions. Other browsers will ignore this line of code. 

*: CSS expressions were introduced in Internet Explorer 5.0 and it allows you to to assign a JavaScript expression to a CSS property.

For more details:

http://www.svendtofte.com/code/max_width_in_ie/

Permalink Leave a Comment

Follow

Get every new post delivered to your Inbox.