Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9167261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:20:49+00:00 2026-06-17T15:20:49+00:00

What I am trying is setting this CSS on element: background: red !important; But

  • 0

What I am trying is setting this CSS on element:

background: red !important;   

But when I try to do this:

 background: yellow;  

it still only shows the red and not the yellow for that one field as I would like it to be (I am not using external CSS).

What I am asking is how to override it, is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:20:51+00:00Added an answer on June 17, 2026 at 3:20 pm

    Ans is YES !important can be overridden but you can not override !important by a normal declaration. It has to be higher specificity than all other declarations.

    However it can be overridden with a higher specificity !important declaration.

    This code snippet in Firefox’s parser will explain how it works:

    if (HasImportantBit(aPropID)) {
      // When parsing a declaration block, an !important declaration
      // is not overwritten by an ordinary declaration of the same
      // property later in the block.  However, CSSOM manipulations
      // come through here too, and in that case we do want to
      // overwrite the property.
      if (!aOverrideImportant) {
        aFromBlock.ClearLonghandProperty(aPropID);
        return PR_FALSE;
      }
      changed = PR_TRUE;
      ClearImportantBit(aPropID);
    }
    

    Good read

    • Specifics on CSS Specificity
    • CSS Specificity: Things You Should Know

    Here’s an example to show how to override CSS

    HTML

    <div id="hola" class="hola"></div>
    

    CSS

    div { height: 100px; width: 100px; }
    div { background-color: green !important; }
    .hola{    background-color:red !important; }
    #hola{    background-color:pink !important;}
    

    and output will be

    enter image description here

    Also we can not override inline !important

    HTML

    <div id="demo" class="demo" style="background-color:yellow !important;"></div>
    

    CSS

    div { height: 100px; width: 100px; }
    div { background-color: green !important; }
    .demo{    background-color:red !important; }
    #demo{    background-color:pink !important;}
    

    the output is

    enter image description here

    jsFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I trying to load and save setting with this code but when I closing
Supposing I'm setting a background image for a web page in CSS like this:
I know this is really dumb but I'm trying to find the advanced settings
I am trying to setting up the background image of the webpage outside the
For other browsers, simply setting #input-element { color: red; } is sufficient to also
I am setting the background-image of some elements using css (some elements have no
Follow-up to this question: Setting background-color of select options in JQuery I have a
I'm trying to make a CSS/javascript dropdown menu (based on this example . This
I'm trying to set the background of an element to no-repeat - I've tried
I'm trying to add a CSS rule that makes the default behaviour to not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.