Sangeetha.V
Sangeetha.V

Reputation: 115

How avoid style inheritance

Am using Jquery. Every page am having tables.For table I have some default style for a particular page. Every tr am having another child table. Child tables I do not need parent table style informations. How to prevent child table from parent table style inheritance property.Please help If you have any solution. Thanks in advance.

Upvotes: 0

Views: 86

Answers (2)

Jørgen
Jørgen

Reputation: 9130

You could use the direct child selector to separate the tables:

.someContainer > table{ /* This would match the parent tables */ }
table table { /* This will match tables within a table */ }

Upvotes: 2

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

You can use not operator

$('table').not('table table').css('background-color','red');

demo


If you want to perform this only with css then you could do:

table{
   /*parent table style here*/
}
table table{
   /*child table style here*/
}

Upvotes: 0

Related Questions