Jump to content
Sign in to follow this  

Help With Inheritance Level?

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

Share this post

Link to post
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*/}

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...