How to define a class for a table to control table row style

I am wondering if I can define a class that could also manage row styles in a table.

Suppose I define a class "aTable"

.aTable { width:800px; border-spacing:2px; } 

I also want to define line styles. Therefore, when I assign this class to a table, all rows in this table will follow the design, say, background-color: # e9e9e9;

+6
source share
3 answers

You can achieve this as follows:

 .aTable { width: 800px; border-spacing: 2px; } .aTable tr { background-color: #DDD; } 
+11
source

To give the whole row a background color, you have assigned a background color to each cell in that row, i.e.

 .aTable tr td { background-color: #e9e9e9: } 

You can always select specific classes or elements in a css class definition like this.

+1
source

I like to use less to make CSS a lot easier and cleaner. Then you can do this:

 .aTable { width: 800px; border-spacing: 2px; tr { background-color: #DDD; } } 
0
source

All Articles