Jump to content

Parent - Child CSS Inline


brad_mn1988

Recommended Posts

Hi,I want to use the Parent - Child feature for inline style code only.I cannot affect the header code whatsoever for this purpose, so inline is the only way I can accomplish what I want.With external CSS you can write:

div table {background-color:red;}

and it should (if I wrote the example correctly) set a table's background to red only if it is enclosed within a set of div tags.what if you wanted to use an inline CSS code? That is, if I started with this (inside HTML of course):

<div style="???"><table><tr><td>Hello W3Schools</td></tr></table></div>

How would I accomplish assigning the Child table's background-color to red by replacing the '???' with the right CSS?I know I could put in a style attribute directly in the table tag, but for complex reasons that would bore you, I can't. I need a one-shot inline CSS syntax to affect the immediate entity and any of it's Children tags... is that possible?Thanks in advance for any help. (PS: this is an extension of a reply I posted to a 'tables' topic here, but I was told that was 'hijacking', I apologize since I thought I was being polite by 'piggybacking' and not starting a whole new topic, and I thought 'hijacking' was taking a topic off of its intended course [like what a plane hijacker does] not extending the same course. But I could be wrong -- I guess it depends where 'piggybacking' ends and 'hijacking begins' -- Anyway, my apologies!)

Link to comment
Share on other sites

<div style="background-color:red;"><table>  <tr>    <td>Hello W3Schools</td>  </tr></table></div>

The above way is the inline way to do it.The below way to do it is through CSS.

.parent {  background-color: red;}

<div class="parent"><table>  <tr>    <td>Hello W3Schools</td>  </tr></table></div>

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
×
×
  • Create New...