views:

90

answers:

3

If you want to assign the same style to a group of descendants, why isn't there an easy way to do this with CSS?

Say you have an HTML table as follows:

<table id='myTable'>
  <tr>
    <th></th>
    <th></th>
    <th></th>
  </tr>
  .
  .
  .
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>

Why do you have to style all column headings and cells with the following selector?

#myTable tr, #myTable td {}

Why isn't there a syntax similar to the following?

#myTable (tr,td) {}
+3  A: 

You may have to take that up with W3C.

contagious
A: 

Short of taking it up with the W3C, you could use jQuery for a similar sort of thing

$('#myTable').find('tr, td');

Of course, JS isn't always enabled and it would not be a good idea to rely on this. You're just going to have to list out all your selectors!

alex
@alex - tx, I was wondering what the history/rationale was of precluding this type of thing in CSS
eft
Probably just the W3C doing things a bit funny... they do that a bit.
alex
A: 

Because.

.

levik