Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS specific table

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?

like image 837
John Doe Avatar asked Jul 02 '12 01:07

John Doe


People also ask

How do I apply a style to a specific table in HTML?

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.

Can you use CSS to style a table?

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.

How do I make two tables with different 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.


2 Answers

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'!

like image 195
brezanac Avatar answered Sep 21 '22 15:09

brezanac


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; } 
like image 39
John Conde Avatar answered Sep 22 '22 15:09

John Conde