-
Pseudo class syntax
I'm seeking center justification for the first and second columns of each row. The syntax I'm using is incorrect. Can someone please lend a hand?
Code:
table.praises-be td {
border-style: solid;
border-width: 1px;
border-color: #848482;
margin: auto;
nth-child: {text-align: center;};
nth-child(2): {text-align: center;};
}
A.
-
Code:
table.praises-be td {
border-style: solid;
border-width: 1px;
border-color: #848482;
margin: auto;
}
table.praises-be td:nth-child(2) {text-align: center;}
I am not sure why you are calling 'nth-child:' so I ignored it.
-
DW,
Your solution works (as you knew it would)!
I called the nth-child because I wanted the contents of column one centered as well. So I added a line to what you provided, as follows:
Code:
table.praises-be td:nth-child(2) {text-align: center;}
table.praises-be td:nth-child(1) {text-align: center;}
I assume both lines can be combined, although when I tried to do it, CSS hiccuped.
The book I've been trying to use is less than helpful. For example, its description did not enable me to discern whether nth-child without a subscript defaults to nth-child(1). Regardless, I thank you.
A.
-
You should be able to combine them to one line.
Code:
table.praises-be td:nth-child(2), table.praises-be td:nth-child(1) {text-align: center;}
I havent really heard of that happening before but I am not that pro at CSS (about the nth-child defaulting to nth 1.
-
DW,
Many thanks. I'll play with it. And, in the meanwhile, I'll mark the issue "resolved."
A.