Assigning attributes to children of a particular element id or class

I am fumbling around building a web app and am looking for an answer to a CSS question that I have.
I want to identify to CSS attributes on the row, header, and column children of a table with a particular id or class. I want to display all data entry tables in a particular way but not necessarily all tables.
What I am doing now is defining a style in each web page of …

<style type="text/css">
    table {
        border-color: #b5cb88;
        border-style: solid;
    th {
        width: 40%;
        text-align: left;
        color: White;
        font-weight: bold;
        background-color: #758c48;
        border-color: inherit;
        border-color: inherit;

… and I would like to put that in a css file without having the TH attributes apply to all tables.

jim murray

You are THINKING wrong

You define an ID ( or class if you need the attributes to apply to multiple elements) and then, in the HTML you add the class or ID to the tables you want to target… that’s the way CSS works. BTW, you cant really style TH, TRs TBODY, THEAD, or TFOOT, per say ( tho what you have so far WILL INHERIT TO THE TD… hope that makes sense.

Anyway, back to the original Q.

if you want to target a specific table you coud do

#targeted{your :rules;}
or even
table.targeted{your :rules;}

this will leave ALL TABLES alone UNLESS they have the class /id of “targeted”. Yes rules given to all tables ala table{your:general rules;} will still cascade down and be applied unless they are overwritten in your more specific (#target/.target) declarations… It would be illogical to expect otherwise of general rules targeting all elements ( such as table) …I mean a table with the ID of “targeted” is still a table after all… :wink: )