0

I've got a HTML/CSS code, which reacts a little weird (in my opinion). Or I just don't understand inheritance of styles.

The following code snippet is what causes the problem:

enter image description here

You can see I've got a table with the class formula. and on the right side you can see that every table.formular td gets a padding.

Below, in one of the tds of the formular table I've got a new table with the class tabelle-rubrikbar. This table contains a td with the class customSearch-InnerTable-td which should overwrite the padding. But in this case the inherited formular td is overwriting the customSearch-InnerTable-td.

1
  • 1
    You should include sufficient code as text in the question, instead of a mere partial screenshot. In this case, there happens to be sufficient information to guess what the real problem is (it has nothing to do with inheritance). Commented Jan 20, 2014 at 12:37

4 Answers 4

4

you should use an higher specificity for your rule, e.g.

table.formular td.customSearch-InnerTable-td { ... }

For further explanation see http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

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

5 Comments

I think td.customSearch-InnerTable-td will be enough
it's not enough since his first rule is table.formular td
Works for chrome, thanks. But IE won't accept that this is higher priority :(
@Loki: why not? this is css should overwrite the previous one even on IE6. Or are you talking about a specific issue/bug?
Ah IE had the css in cache. That's why it didn't work. Thank you :D
0

Just be more specific with your declaration. The more you narrow down the css style the higher gets is priority over other styles

It behaves like this:

td < td.class so give your class a higher priority like

.tabelle-rubrikbar tr td.customSearch-InnterTable-td

2 Comments

that example was not like "use this style" it was just to clarify that the td.class style got higher priority than just td
I withdrew my comment.
-1

You should try adding !important at the end of customSearch-InnerTable-td like

customSearch-InnerTable-td {
padding: 0px 0px 0px 0px !important;}

2 Comments

Try reading up here - [link] (w3.org/TR/CSS2/cascade.html#important-rules)
Don't use !important unless you don't have other choice!
-2

mark the css of the customSearch-InnerTable-td as "!important" (without the quotes) and it will increase the priority of the styling you have used in the customSearch-InnerTable-td. Its a small hack which works fine always

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.