I have an HTML document where I have two different tables. One is class Alpha and one is class Beta. I want to assign this css to class Beta only...
td { border-style:solid; border-top:thick double #ff0000; }
I can not figure out how to assign this only to Beta. Does anyone know how?
If you want to apply a style to a specific column or row (but not on others), use :nth-child() property from CSS3. This selector is used to apply a style to the element number 'n' inside a parent element.
CSS provides a number of attributes for styling tables. These attributes allow you to—among other things—separate cells in a table, specify table borders, and specify the width and height of a table. This tutorial will discuss, with examples, how to style a table using CSS.
You need to assign different classes to each table. and use them in your html code. Show activity on this post. Of course, just assign seperate css classes to both tables.
Just apply the .beta
class selector to the entire table and change your CSS code to apply a rule only to td
decedents of .beta
like this:
<table class="beta"> <tr> <td>...</td> <td>...</td> </tr> </table>
.beta td { border-style:solid; border-top:thick double #ff0000; }
If you need to apply the rule to multiple elements within .beta
simply add an additional selector like this:
.beta td, .beta th { border-style:solid; border-top:thick double #ff0000; }
Qapla'!
CSS lets you get specific with what elements rules are to be applied to. Just add this rule to the table.Beta td cell declaration and you're done.
table.Beta td { border-style:solid; border-top:thick double #ff0000; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With