Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How simplify css style for tables

Tags:

css

I have a css code I want to improve. Actually this code was copy-pasted from Chrome styles inspector. But I'm stuck with trying to simplify it into one rule using nesting to get "clean" styles:

.table > thead > tr > th, .table > thead > tr > td,
.table > tbody > tr > th, .table > tbody > tr > td,
.table > tfoot > tr > th, .table > tfoot > tr > td {
  border-top: 1px solid #000;
}

Is there a way to make it simplier?

like image 485
Paul Avatar asked Dec 18 '22 16:12

Paul


2 Answers

In table we find <th> and <td> in <thead>, <tbody> and <tfoot> and in above css all the things are targeted so why not simply use this

.table th, .table td{
  border-top: 1px solid #000;
}

This will also target all <th> and <td> in table.

like image 168
Gaurav Aggarwal Avatar answered Jan 15 '23 19:01

Gaurav Aggarwal


You can omit middle part as you are selecting all parts from table

.table th,
.table td {
    border-top: 1px solid #000;
}
like image 28
Justinas Avatar answered Jan 15 '23 20:01

Justinas