Jump to content

Help With Inheritance Level?


banzemanga

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 }

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...