Is there a shortcut to customize! Important for every property in the CSS file?

I have a large CSS file for which I would like to add !important to each CSS property. Is there a single line shortcut to create the whole !important Css file !important ?

+4
source share
4 answers

If your goal is to override styles by importing another stylesheet, you should use the order of priority.

 <head> <title>Title</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="style-override.css" rel="stylesheet" type="text/css" /> </head> 

Here, style.css is the original, and style-override.css will contain your new custom css. These styles override styles from style.css . This means that you do not need to use !important because the style is overwritten.

Alternatively, you can add CSS reset to remove all styles and build on top of it.

 <head> <title>Title</title> <link href="style.css" rel="stylesheet" type="text/css" /> <link href="reset.css" rel="stylesheet" type="text/css" /> <link href="style-override.css" rel="stylesheet" type="text/css" /> </head> 

Check out CSS reset at http://meyerweb.com/eric/tools/css/reset/ and add it to reset.css.

+4
source

No. Also, do not abuse !important : this should be the last resort. The effect of applying !important to all CSS declarations is equivalent to the absence of !important added to each declaration.

Use more specific selectors ( #id ) instead of adding !important if you want a specific property to take precedence.

+4
source

No. Using! It should be important only in specific cases different from others. It is not intended to apply to the entire style sheet document.

If you are thinking of rewriting many rules, why not just include the rules you want to rewrite?

+2
source

Is it impossible to move the link to the CSS file to the last link and therefore takes precedence over all other CSS files over it?

0
source

All Articles