I am very new to CSS but trying to format alignment in a HTML Table that contains (3) columns (each column with a header). I want the first column aligned center, the 2nd left and the third right.
Table {
font-family: Arial, Helvetica, sans-serif;
background-color: #eeeeee;
border-collapse: collapse;
width: 100%;
}
Table td,
table th {
font-size: 10px;
border: 1px solid #ddd;
padding: 3px 3px;
}
Table th {
font-weight: bold;
padding-top: 6px;
padding-bottom: 6px;
background-color: #00b0f0;
color: white;
}
/* first tr and then first th (Column 1)*/
table tr: first-child th: first-child{
text-align: center;
}
/* all cells under the first column */
table tr td: first-child {
text-align: center;
}
/* first element of the second column (Column 2) */
table tr: first-child th: nth-child(2) {
text-align: left;
}
/* all cells under the second column */
table tr td: nth-child(2) {
text-align: left;
}
/* first element of the third column (Column 3) */
table tr: first-child th: nth-child(3) {
text-align: right;
}
/* all cells under the third column */
table tr td: nth-child(3) {
text-align: right;
}
Any assistance would be appreciated.
:andfirst-childin: first-child. Likewise for nth-child.Alohcicomment. It must betable tr:first-child th:first-child {... etc.