15

Is there any way to override inline CSS without using !important and without using JavaScript?

For example:

<div style="background-color: red;"></div>

I was wondering if it can be overridden without:

div {
    background-color: blue !important;
}
2
  • I'm curious. What's your scenario? Commented Apr 26, 2013 at 10:23
  • I'm using kendoui which injects a lot of it's own inline css. I don't like using important and I don't like writing javascript for things which should be handled in CSS. So I have the options to do these but would like it if there were a cleaner way... Commented Apr 26, 2013 at 10:38

3 Answers 3

20

No, inline style takes precedence, you can override it only with !important.

Sign up to request clarification or add additional context in comments.

1 Comment

I thought so too, tried all kinds of CSS specificity
2

I'm afraid the !important clause is specifically created as the solution for this. It would be impractical for CSS to implement different degrees of priority, apart from the now-used style block < inline < !important priority.

Comments

1

Try this:

div[style] {
  background: blue !important;
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.