Jump to content

Help With Inheritance Level?


banzemanga
 Share

Recommended Posts

I am not sure what it is called in CSS but i think it has to do with inheritance.Let's say i have the following HTML table:

<table id="styleme">	<tbody>		<tr>				<td>Hello</td>				<td>World</td>		</tr>	</tbody></table>

So i want my CSS to give a background color at the td tag on the table with id "styleme" and not the td tags of other tables.I know that if i want to specifically give a style to the table tag i could do:

table#styleme { //whatever style }

But i want to give style to my td tag without giving it a class name or id but going though the fact that table with the id is parent of the td tag i want to style..Edit: Never mind i found the solution. I have to include the tag-name of each cascaded element:

table#styleme>tbody>tr>td { //the style for the td tag }

Edited by banzemanga
Link to comment
Share on other sites

The descendent selector is better (and supported by more browsers) than the child selector.Try this:

table#styleme td {/* Selects all <td> elements inside #styleme*/}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...