470,634 Members | 2,103 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,634 developers. It's quick & easy.

element.style.position="relative !important";


I tried the following and everything worked fine.


Then I tried to make the CSS rule important and it didn't work. The
positioning was all wrong in Safari and very jerky in Firefox.

element.style.position="relative !important";

Am I doing this correctly?


Mar 18 '06 #1
2 4797

Still no good in Safari when the rule is inserted with !important. It
is the same behavior as if I do not insert the rule at all: the
positioning is all wrong. If the rule is defined in a stylesheet file
then !important doesn't cause any problems.

I was wrong, it is not jerky in Firefox. I had to restart firefox for
other reasons and now it is ok. However, when I look in the DOM
inspector the rule shows up as relative but not as important. If I
hardcode the style into my HTML document in the element's style tag,
then the Firefox DOM inspector shows that the rule is important. Hmmmm

Is JavaScript support for inserting !important rules just not ready


Mar 18 '06 #2
On 18/03/2006 20:49, pe**********@gmail.com wrote:

Then I tried to make the CSS rule important and it didn't work. [...]

element.style.position="relative !important";

Am I doing this correctly?

No. The assigned string should only contain the declaration value.

To set a priority, call the setProperty method, but this should not be
necessary. In-line style declarations are the most specific possible,
and will take precedence unless there is an !important declaration


Michael Winter
Prefix subject with [News] before replying by e-mail.
Mar 18 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jamie Jackson | last post: by
5 posts views Thread by balakrishnan.dinesh | last post: by
3 posts views Thread by rsrimantula | last post: by
4 posts views Thread by Julek | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.