I have an HTML table with numerous columns. I want to set text-align: center
on all columns except one.
I've heard that both using !important and unnecessary nesting is frowned upon. What is the "best" way to achieve this?
- Using
!important
:
#my-table td {
padding: 5px;
text-align: center;
}
.my-table-special-td {
text-align: left !important;
}
- Unnecessary nesting:
#my-table td {
padding: 5px;
text-align: center;
}
#my-table .my-table-special-td {
text-align: left;
}
Or some other method?
By "best" I mean: * Conformance to CSS best practices * Good performance