Reputation: 73918
Hi I have a generic DIV with a Css Role applied.
I would like to know if CSS allows to set the style for an HTML Tag inside a DIV (only for DIV with that Role) which has a Css Role.
Please let me know your thoughts. Thanks for your time on this.
<div class="Role">
<table></table>
</div>
.Role
{
// Style for <table> tag.
}
Upvotes: 0
Views: 140
Reputation: 59483
Just see the CSS selectors - pattern matching. You can use one of the following, depends on your needs:
.Role * { ... } /* matches any tag in div class="Role" */
.Role > * { ... } /* matches any tag which is direct child of div class="Role" */
You can replace * with any particular selector (tag, class, etc.)
Upvotes: 0
Reputation: 14909
You have several options to go:
The descendant selector selector .Role table
, for example, select for apply all the table that are contained into an element, whatever, with class Role.
The child selector .Role > table
will apply the associated rules to the tables that are child (not descendant) of the element with class Role
For example, consider this html fragment:
<div class="Role">
<table id="t1">
<tr><td>
<table id="t2">
....
</table>
</td></tr>
</table>
</div>
Upvotes: 1
Reputation: 262939
It is indeed possible, either with a descendant selector:
.Role table {
// Style for <table> element.
}
Or with a child selector:
.Role > table {
// Style for <table> element.
}
Upvotes: 2
Reputation: 438
To style the table in div with role class you need
.Role table {
//style for table tag
}
Upvotes: 2