Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a shortcut for setting !important on every property in a CSS file?

Tags:

css

I have a large CSS file for which I would like to add !important to every CSS property. Is there one-line shortcut to make a whole .css file !important?

like image 804
Randomblue Avatar asked Dec 22 '22 08:12

Randomblue


1 Answers

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

<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 the style.css is the original and style-override.css would contain your new custom css. These styles will override the styles from style.css. This means you won't need to use !important because the style is overwritten.

Alternatively you could add in a CSS reset to remove all styles and build on-top of that.

<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 a CSS reset at http://meyerweb.com/eric/tools/css/reset/ and add it to reset.css.

like image 79
Kirk Avatar answered Apr 22 '23 09:04

Kirk