...

View Full Version : CSS - additional rule for specific internal tag



knkk
08-04-2007, 10:10 AM
I want to create a style rule (class) and give it in the <TABLE> tag (e. g. <TABLE CLASS="blah">. But whenever there is a <TD> in the table, I want an additional rule for the td (e. g. give a border to that td, but not to each element in the td, or any other element in the table), without having to write another class and then do <TD CLASS="blah1">. This is to avoid typing multiple <TD CLASS="blah1"> with each cell and therefore to cut down on HTML cource code.

So my HTML would look like:



<TABLE CLASS="blah">
<TR>
<TD>something
</TD>
</TR>
<TR>
<TD>something
</TD>
</TR>
</TABLE>


instead of


<TABLE CLASS="blah">
<TR>
<TD CLASS="blah1">something
</TD>
</TR>
<TR>
<TD CLASS="blah1">something
</TD>
</TR>
</TABLE>


Does anyone have any idea how I write the style sheet? I tried this:

.blah,
.blah a: link,
.blah a: visited
{ primary rules }
td.blah: { additional rule for td }

but it does not work.

Thank you very much for your time!

Jutlander
08-04-2007, 10:13 AM
How about just:


td {
border: 1px solid #555;
}

_Aerospace_Eng_
08-04-2007, 10:14 AM
table.blah td {additional rules}

knkk
08-05-2007, 08:28 AM
Hi _Aerospace_Eng_ and Jutlander

Thank you for your time! I did something pretty close:



.blah td {additional rule for td }


...which worked. Thank you again!

Jutlander
08-05-2007, 12:04 PM
Just FYI, you did the same as Aero suggested, except for writing 'table' before the period. This is optional whether you want to do that or not, I do it too because it makes it easier to keep track of classes and ID's.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum