Is there a way to tell an html element to ignore any stylesheets?

Assuming you could set a unique class or id on that element you could use the (limited browser support) property all and set it to unset or initial

Something like

<div class="ignore-css"><div>

and

.ignore-css{all:unset;}

you can eaither add cascading styles like:

#id1 .class1 select

or

.class:width:200px !important

The !important will make it use the style you want rather than the global one, but if you have to overwrite it it can get a little tricky. You have to use a combination of both.


You can override another style using "!important", like this:

a {color: red !important}

Or using a more specific selector:

*               // a=0 b=0 c=0 -> specificity =   0 
LI              // a=0 b=0 c=1 -> specificity =   1 
UL LI           // a=0 b=0 c=2 -> specificity =   2 
UL OL+LI        // a=0 b=0 c=3 -> specificity =   3 
H1 + *[REL=up]  // a=0 b=1 c=1 -> specificity =  11 
UL OL LI.red    // a=0 b=1 c=3 -> specificity =  13 
LI.red.level    // a=0 b=2 c=1 -> specificity =  21 
#x34y           // a=1 b=0 c=0 -> specificity = 100 
#s12:not(FOO)   // a=1 b=0 c=1 -> specificity = 101

See specificity documentation here.


UPDATE:

For example:

You have a global rule:

a {color: blue}

But you want your links red. So, you must create the rule below:

a {color: red !important}

If the global rule also has "!important", you must use a more specific selector: So, you may use:

body a {color: red !important}

there is no easy way to do what you are asking, one approach is to create a CSS class that resets all appropriate attributes for a specific element and its children to make it more complete, here is a good starting point Element specific CSS reset

Tags:

Html

Css