3 replies [Last post]
Peeyush
Peeyush's picture
Offline
newbie
Last seen: 4 years 30 weeks ago
Timezone: GMT+5.5
Joined: 2010-01-07
Posts: 5
Points: 9

Hello,

I would like to know about !important property in css.

I am using this function in class like below example.

------------------------------------------------------------------------
.show_bg{
background:#FAFAFA!important;
padding-top:18px!important;
margin-top:-10px!important;
}
------------------------------------------------------------------------

can i use !important one time for all property instead of giving separately.

Plz suggest me if there is any solution for that.

Thanks in advance

Regards
Peeyush Gupta

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 1 week 3 days ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

You have to apply !important

You have to apply !important to each declaration in a rule set; it can't be used just once to apply to all declarations. But really, if you need to apply !important to each declaration like you have, you're doing something wrong. !important should only be used in limited situations like overriding inline styles.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference

Peeyush
Peeyush's picture
Offline
newbie
Last seen: 4 years 30 weeks ago
Timezone: GMT+5.5
Joined: 2010-01-07
Posts: 5
Points: 9

Use */> tags.

Thanks for your help.

I know you are right. But conditions are happen where i need to use
declaration in every rule set.

Well plz let me know about this tag */>

Thanks in advance.

Regards
Peeyush Gupta
919928362554

Tyssen
Tyssen's picture
Offline
Moderator
Brisbane
Last seen: 1 week 3 days ago
Brisbane
Timezone: GMT+10
Joined: 2004-05-01
Posts: 8201
Points: 1386

Peeyush wrote: But conditions

Peeyush wrote:

But conditions are happen where i need to use declaration in every rule set.

Well it's hard to say without seeing any code, but I've never come across an instance where you need to use it for every rule set so I think your conditions probably need changing.

Peeyush wrote:

Well plz let me know about this tag */>

It's the button you press when you want to enter code with your posts on this forum.

How to get help
Post a link. If you can't post a link, jsFiddle it.
My blog | My older articles | CSS Reference