inline-stylesen un documento tienen la prioridad más alta, por ejemplo, diga si desea cambiar el color de un divelemento a blue, pero inline styletiene una colorpropiedad establecida enred
<div style="font-size: 18px; color: red;">
Hello World, How Can I Change The Color To Blue?
</div>
div {
color: blue;
/* This Won't Work, As Inline Styles Have Color Red And As
Inline Styles Have Highest Priority, We Cannot Over Ride
The Color Using An Element Selector */
}
Entonces, ¿debería usar jQuery / Javascript? - La respuesta es NO
Podemos usar element-attrCSS Selector con !important, nota, !importantes importante aquí, de lo contrario no anulará los estilos en línea.
<div style="font-size: 30px; color: red;">
This is a test to see whether the inline styles can be over ridden with CSS?
</div>
div[style] {
font-size: 12px !important;
color: blue !important;
}
Manifestación
Nota: Usar !importantSOLO funcionará aquí, pero he usado el
div[style]selector para seleccionar específicamente divtener style
atributo