Tuesday, August 02, 2005

IE style rule gotcha

I've been busy with massive project at the day job (launching soon, hope to mention it in detail here), and soon I'll be preoccupied with a C++ course, so I don't expect to be posting with any regular frequency here for the remainder of the summer.

I will share this, though: just because you can set style properties with a string:

elm.style.fontSize = "12px";

...doesn't mean IE will accept any old string:

elm.style.fontSize = "12px !important";
/* causes 'invalid argument' error in IE */

Firefox has no problem with this. Of course.

7 Comments:

At 1:02 AM, Blogger wpbasti said...

The question is it generally allowed to use this "!important" statement inside a runtime style defintion or is this only allowed in CSS definition blocks.

You can also set the runtime style in IE which will make it more "important" to the browser.

 
At 7:10 AM, Blogger alan said...

Such a tease. Looking forward to hearing about the upcoming project.

 
At 5:43 AM, Blogger Jonathan Snook said...

just to elaborate on what wpbasti said... instead of .style. use .runtimeStyle. for IE.

 
At 2:35 AM, Blogger Roland Bouman said...

I guess this occurs because something like

style.fontSize

is *NOT* the same as the corresponding css property, in this case:

font-size

style.fontSize is the object representation of that css property.

There's actuall

 
At 2:36 AM, Blogger Roland Bouman said...

(Sorry, continuing my previous post)

There's actually a property that you can use to do this:

style.cssText

so,

style.cssText = "font-size = 30pt !important"

is happily swallowed by IE

 
At 8:46 AM, Blogger Helplessness said...

what about the _height property.

min-height property not works in IE, but _height is work.

 
At 3:02 AM, Blogger Tania said...

Find the way to fell your personal style! It's the most important part in your image!

 

Post a Comment

<< Home