Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selecting parent table in css

Tags:

css

suppose I have a nested tables in html like this

<table>
<tr>
  <td><table>
    <tr>
      <td></td>
      <td></td>
    </tr>
  </table></td>
  <td></td>
</tr>
<tr>
  <td><table>
    <tr>
      <td></td>
      <td></td>
    </tr>
  </table></td>
  <td></td>
</tr>
</table>

Now I want to do style only to the parent table without adding any markup like any class or IDs. so how can I do that only in css.I just want to select the parent table.

like image 210
NewUser Avatar asked Feb 04 '26 21:02

NewUser


1 Answers

You can't specify the parent table in a selector, but you can specify the child tables, so you can style all tables, and then override the style for child tables:

table { background: red; }
table table { background: none; }
like image 99
Guffa Avatar answered Feb 06 '26 12:02

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!