Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dumb question about CSS classes

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
US
if i have an external CSS

table.block {
font-family: Tahoma, taipei, Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
border-style: solid;
padding: 0px;
margin: 0px;
background-color: #FFFFFF;
border-color: #000088;
border: 1px;
}
td.block {
text-align: left;
text-indent: 5px;
background-color: #FFFFFF;
}
th.block {
background-color: #000088;
text-align: center;
font-family: Tahoma, taipei, Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #FFFFFF;
padding: 10px;
}

in my HTML does each element of the table have to class-"th"

how can i just enter the class one time for the whole HTML table? -Pete[noevil]
 
oops i meant to say class="block" do i have to have that in each table element? -Pete[noevil]
 
Yes the way you did the CSS. Or to globally change every "table" element with CSS

table{
blah, blah, blah
}

every td element
td{
blah, blah, blah
}

does that help?
-pete
 
well what I am hoping for is a way to say

<table class=&quot;block&quot;>
<tr><td>blah blah</td></tr>
</table>

w/o embedding the class statement in each element?

So by saying in HTML the table is class=&quot;block&quot; will the other elements in that table pick up the block class for <td> and <th> with out me entering <th class=&quot;block&quot;>.

I know what i worte above does not do that. How would i write the CSS to make that happen or am I stuck and that is how it is done, element by element in the HTML page? -Pete[noevil]
 
Ok now i see what your asking. No, elements do not inherit parent element CSS class settings. The &quot;Cascading&quot; part of CSS is regarding the &quot;Styles&quot; not the &quot;elements&quot;.

This is a place where the XML/XSLT transformation mechanism is superior to generating HTML directly.

-pete
 
Hey Pete and Pete, how's it going? Nice names!

I often use this approach:

table.foo { ... } /* styles for <table class=&quot;foo&quot;> */
table.foo tr { ... } /* styles for all <tr>s within <table class=&quot;foo&quot;> */
table.foo td { ... } /* styles for all <td>s within <table class=&quot;foo&quot;> */

Is this what you're looking for?

petey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top