Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS who can tell me about !important?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45233
    Sam
    Participant

    I know this order and i don’t know how to use this !important?
    Today i write a css and find when i use css in my web which is to learn mandarin in shanghai and the page just use the page.css don’t use my yz.css. so i search then find !important,but i don’t know how to use,if you know,
    tell me please.
    Many THX!

    #137119
    CodeGraphics
    Participant

    Don’t use !important.
    But if you must use it, !important is used when you don’t want the style you applied to an element to be altered by another styling somewhere in your css.

    #137128
    Paulie_D
    Member

    Not exactly correct.

    The `!important` option is used to make sure that the style to which you apply it is NOT overridden by styling elsewhere further down your stylesheet.

    It can also be used to make sure the styling is applied to overcome specificity issues.

    Properly managed CSS stylesheets will not normally require the use of this option

    #137132
    CrocoDillon
    Participant

    > It can also be used to make sure the styling is applied to overcome specificity issues.

    If you need !important to make it work and you don’t know why, it’s probably this. Eventually it will be very hard to override rules and you end up using !important on everything. Don’t do that :P Understand how selector specificity works and only use !important when changing that property might break something and you know for sure you won’t ever need to override it, and only then even if you really need it.

    #137302
    Sam
    Participant

    now i see and thank you very much!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.