Reputation: 151
I have this div that I need to change the background color of, however it does not have any class or an id to access it.
<div style="margin-bottom:10px;background-color:#fff;padding:10px;">
</div>
The reason I can't add a class is because I am making an extension for the website, not the actual website, and it needs to access it and change the background color (dark mode).
Upvotes: 0
Views: 49
Reputation: 56754
You can use an attribute selector. Be aware that this will only work
style
) value doesn't change, not in a single character;div
, you need to make your CSS rule !important
to beat the inline style specificity.div[style="margin-bottom:10px;background-color:#fff;padding:10px;"] {
background-color: orange !important;
}
<div style="margin-bottom:10px;background-color:#fff;padding:10px;"></div>
Upvotes: 3