2 replies [Last post]
Franz XD
Franz XD's picture
Offline
newbie
Last seen: 11 years 7 weeks ago
Timezone: GMT-4
Joined: 2011-05-01
Posts: 6
Points: 8

I've been reading documentation all afternoon, and I can't seem to figure this out.

Is there a way to attach style properties to the elements of a table without having to add a class or id tag to each element?

For example, I can use

table.myclass {border:1px}
th.myclass {background-color:#888888}

and create a table with

<table class="myclass">
  <tr>
    <th class="myclass">content</th>
    <th class="myclass">content</th>
  </tr>
  <tr>
    <td>content</td>
    <td>content</td>
  </tr>
</table>

But is there a way to code it so that every table of class="myclass" will have table headers with the new color automatically, without having to add the class tag to each th tag?

Deuce
Deuce's picture
Offline
Guru
Somewhere, USA
Last seen: 4 years 50 weeks ago
Somewhere, USA
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4424
Points: 1843

table.myclass th {

table.myclass th { background-color:#888; }

all ยป http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

Franz XD
Franz XD's picture
Offline
newbie
Last seen: 11 years 7 weeks ago
Timezone: GMT-4
Joined: 2011-05-01
Posts: 6
Points: 8

Thanks a bunch. My code looks

Thanks a bunch. My code looks so much nicer.

Also, I see where this was in the docs now, but I couldn't recognize it with the generic example. : \