Okay so i got a really specific css i need to set for the first 3 rows and only on the 2nd td of those 3 rows. is there anyway to target only them in css rules?
right now i am trying like this
here is the render
<tr className={getRowColor(props, l, i)}>
<td>{i + 1}</td>
<td className="info-table-cell{l.info}</td>
</tr>
and here it is the second td in this row that i want to target for the first 3 rows only. And right now i try like this
.info-table-cell td:nth-child(1) {
background-color: #FFF45E;
}
.info-table-cell td:nth-child(2) {
background-color: #DCDCDC;
}
.info-table-cell td:nth-child(3) {
background-color: #FFC933;
}
but that does nothing. Anyone who knows how to do this?
Hope this helps you. I have added a red background color for nd td of first 3 rows. Try it:
table {
width: 100%;
}
table tr td {
border: 1px solid #000;
}
table tr:first-child td:nth-child(2),
table tr:nth-child(2) td:nth-child(2),
table tr:nth-child(3) td:nth-child(2) {
background-color: red;
}
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>
If i understand you correcly, its indeed possible. There are some problem with your code, your not selecting anything because info-table-cell is the td. Here is my approach:
Html
<table class="your-specific-class">
<tr>
<td class="info-table-cell">Content 1</td>
<td class="info-table-cell">Content 2</td>
</tr>
<tr>
<td class="info-table-cell">Content 1</td>
<td class="info-table-cell">Content 2</td>
</tr>
<tr>
<td class="info-table-cell">Content 1</td>
<td class="info-table-cell">Content 2</td>
</tr>
</table>
CSS
.your-specific-class tr:nth-child(1) td:nth-child(2){
background-color: #FFF45E;
}
.your-specific-class tr:nth-child(2) td:nth-child(2){
background-color: #DCDCDC;
}
.your-specific-class tr:nth-child(3) td:nth-child(2){
background-color: #FFC933;
}
Example here: https://codepen.io/lauritzz77/pen/XoLjXr
Related
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
table, th, td {
border: 2px solid black;
padding: 0.5em 1em;
border-collapse: collapse;
}
.theadfixed {
position: sticky; top: 0;
color: black;
background-color: green;
}
.theadfixed tr {
border-color: black;
border: 2px solid black;
}
.theadfixed th{
text-align:center;
border: 2px solid black;
}
</style>
</head>
<body>
<table>
<thead class='theadfixed'>
<tr>
<th colspan="2" > Size </th>
</tr>
<tr>
<th> Length </th>
<th> Width </th>
</tr>
</thead>
<tbody>
<tr>
<td>654</td>
<td>1</td>
</tr>
<tr>
<td>256</td>
<td>2</td>
</tr>
<tr>
<td>78</td>
<td>3</td>
</tr>
<tr>
<td>654</td>
<td>4</td>
</tr>
<tr>
<td>654</td>
<td>5</td>
</tr>
<tr>
<td>256</td>
<td>6</td>
</tr>
<tr>
<td>78</td>
<td>7</td>
</tr>
<tr>
<td>654</td>
<td>8</td>
</tr>
<tr>
<td>654</td>
<td>9</td>
</tr>
<tr>
<td>256</td>
<td>10</td>
</tr>
<tr>
<td>78</td>
<td>11</td>
</tr>
<tr>
<td>654</td>
<td>12</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>654</td>
<td>17</td>
</tr>
<tr>
<td>256</td>
<td>18</td>
</tr>
<tr>
<td>78</td>
<td>19</td>
</tr>
<tr>
<td>654</td>
<td>20</td>
</tr>
<tr>
<td>654</td>
<td>21</td>
</tr>
<tr>
<td>256</td>
<td>22</td>
</tr>
<tr>
<td>78</td>
<td>23</td>
</tr>
<tr>
<td>654</td>
<td>24</td>
</tr>
<tr>
<td>654</td>
<td>25</td>
</tr>
<tr>
<td>256</td>
<td>26</td>
</tr>
<tr>
<td>78</td>
<td>27</td>
</tr>
<tr>
<td>654</td>
<td>28</td>
</tr>
<tr>
<td>654</td>
<td>29</td>
</tr>
<tr>
<td>256</td>
<td>30</td>
</tr>
<tr>
<td>78</td>
<td>31</td>
</tr>
<tr>
<td>654</td>
<td>32</td>
</tr>
</tbody>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
table, th, td {
border: 2px solid black;
padding: 0.5em 1em;
border-collapse: collapse;
}
.theadfixed {
position: sticky; top: 0;
color: black;
background-color: green;
}
.theadfixed tr {
border-color: black;
border: 2px solid black;
}
.theadfixed th{
text-align:center;
border: 2px solid black;
}
</style>
</head>
<body>
<table>
<thead class='theadfixed'>
<tr>
<th colspan="2" > Size </th>
</tr>
<tr>
<th> Length </th>
<th> Width </th>
</tr>
</thead>
<tbody>
<tr>
<td>654</td>
<td>1</td>
</tr>
<tr>
<td>256</td>
<td>2</td>
</tr>
<tr>
<td>78</td>
<td>3</td>
</tr>
<tr>
<td>654</td>
<td>4</td>
</tr>
<tr>
<td>654</td>
<td>5</td>
</tr>
<tr>
<td>256</td>
<td>6</td>
</tr>
<tr>
<td>78</td>
<td>7</td>
</tr>
<tr>
<td>654</td>
<td>8</td>
</tr>
<tr>
<td>654</td>
<td>9</td>
</tr>
<tr>
<td>256</td>
<td>10</td>
</tr>
<tr>
<td>78</td>
<td>11</td>
</tr>
<tr>
<td>654</td>
<td>12</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>654</td>
<td>17</td>
</tr>
<tr>
<td>256</td>
<td>18</td>
</tr>
<tr>
<td>78</td>
<td>19</td>
</tr>
<tr>
<td>654</td>
<td>20</td>
</tr>
<tr>
<td>654</td>
<td>21</td>
</tr>
<tr>
<td>256</td>
<td>22</td>
</tr>
<tr>
<td>78</td>
<td>23</td>
</tr>
<tr>
<td>654</td>
<td>24</td>
</tr>
<tr>
<td>654</td>
<td>25</td>
</tr>
<tr>
<td>256</td>
<td>26</td>
</tr>
<tr>
<td>78</td>
<td>27</td>
</tr>
<tr>
<td>654</td>
<td>28</td>
</tr>
<tr>
<td>654</td>
<td>29</td>
</tr>
<tr>
<td>256</td>
<td>30</td>
</tr>
<tr>
<td>78</td>
<td>31</td>
</tr>
<tr>
<td>654</td>
<td>32</td>
</tr>
</tbody>
</table>
</body>
</html>
Above is the entire file.
I would like a vertical black line separating the "Length" and 'Width" column labels.
I think the background color covers up the border color.
I've tried different things such as:
border-color: black;
border: 2px solid black;
But nothing seems to work.
Can you help me make the th borders visible? Thanks
Try This :
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
table,
td,
th {
border-collapse: collapse;
padding: 0.5em 1em;
border: 2px solid black;
}
.theadfixed th {
text-align: center;
border: 2px solid black;
background-color: green;
position: sticky;
top: 0;
}
.theadfixed th::before {
content: '';
position: absolute;
height: 1px;
width: 100%;
top: -1px;
left: 0;
background-color: black;
}
.theadfixed th::after {
content: '';
position: absolute;
width: 100%;
bottom: 0;
left: 0;
background-color: black;
}
.SolveStickProblem{
top:35px!important;border:2px solid black;
}
</style>
</head>
<body>
<table>
<thead class='theadfixed'>
<tr>
<th colspan="2" > Size </th>
</tr>
<tr>
<th class="SolveStickProblem"> Length </th>
<th class="SolveStickProblem"> Width </th>
</tr>
</thead>
<tbody>
<tr>
<td>654</td>
<td>1</td>
</tr>
<tr>
<td>256</td>
<td>2</td>
</tr>
<tr>
<td>78</td>
<td>3</td>
</tr>
<tr>
<td>654</td>
<td>4</td>
</tr>
<tr>
<td>654</td>
<td>5</td>
</tr>
<tr>
<td>256</td>
<td>6</td>
</tr>
<tr>
<td>78</td>
<td>7</td>
</tr>
<tr>
<td>654</td>
<td>8</td>
</tr>
<tr>
<td>654</td>
<td>9</td>
</tr>
<tr>
<td>256</td>
<td>10</td>
</tr>
<tr>
<td>78</td>
<td>11</td>
</tr>
<tr>
<td>654</td>
<td>12</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>654</td>
<td>17</td>
</tr>
<tr>
<td>256</td>
<td>18</td>
</tr>
<tr>
<td>78</td>
<td>19</td>
</tr>
<tr>
<td>654</td>
<td>20</td>
</tr>
<tr>
<td>654</td>
<td>21</td>
</tr>
<tr>
<td>256</td>
<td>22</td>
</tr>
<tr>
<td>78</td>
<td>23</td>
</tr>
<tr>
<td>654</td>
<td>24</td>
</tr>
<tr>
<td>654</td>
<td>25</td>
</tr>
<tr>
<td>256</td>
<td>26</td>
</tr>
<tr>
<td>78</td>
<td>27</td>
</tr>
<tr>
<td>654</td>
<td>28</td>
</tr>
<tr>
<td>654</td>
<td>29</td>
</tr>
<tr>
<td>256</td>
<td>30</td>
</tr>
<tr>
<td>78</td>
<td>31</td>
</tr>
<tr>
<td>654</td>
<td>32</td>
</tr>
</tbody>
</table>
</body>
</html>
Also here is Docs of HTML Table
Specify border width....
Try this:
.theadfixed th {
text-align:center;
border: 2px solid black;
}
Edit:
Add this to your css:
tbody td:nth-child(odd) {
border-right: 4px solid black;
}
tbody td:nth-child(even) {
border-left: 4px solid black;
}
Final file:
please notice that I have used the snippets in stackoverflow, so you can run it right here and see the result. :)
table, th, td {
border: 2px solid black;
padding: 0.5em 1em;
border-collapse: collapse;
}
.theadfixed {
position: sticky; top: 0;
color: black;
background-color: green;
}
.theadfixed tr {
border-color: black;
border: 2px solid black;
}
.theadfixed th{
text-align:center;
border: 2px solid black;
}
tbody td:nth-child(odd) {
border-right: 4px solid black;
}
tbody td:nth-child(even) {
border-left: 4px solid black;
}
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<table>
<thead class='theadfixed'>
<tr>
<th> Length </th>
<th> Width </th>
</tr>
</thead>
<tbody>
<tr>
<td>654</td>
<td>1</td>
</tr>
<tr>
<td>256</td>
<td>2</td>
</tr>
<tr>
<td>78</td>
<td>3</td>
</tr>
<tr>
<td>654</td>
<td>4</td>
</tr>
<tr>
<td>654</td>
<td>5</td>
</tr>
<tr>
<td>256</td>
<td>6</td>
</tr>
<tr>
<td>78</td>
<td>7</td>
</tr>
<tr>
<td>654</td>
<td>8</td>
</tr>
<tr>
<td>654</td>
<td>9</td>
</tr>
<tr>
<td>256</td>
<td>10</td>
</tr>
<tr>
<td>78</td>
<td>11</td>
</tr>
<tr>
<td>654</td>
<td>12</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
</tbody>
</table>
</body>
</html>
Before going through the code you should know that position:sticky; does not work on <theads> neither <tr>.
So an effective and simple way would be to use postition:sticky; on the the <th> element.
Also, there is no point in setting border property multiple times to the same element as if it would magically fix your issue.
However on scrolling you see that the border around the <th> moves up. Hence to still mimic the border on the top and bottom, css psudeo elements have been added.
If you need further clarification i suggest you to check this post from css-tricks by chris coyier. https://css-tricks.com/position-sticky-and-table-headers/
<!DOCTYPE html>
<html>
<head>
<title>Tesst</title>
<style>
table {
border-collapse: collapse;
}
table,
td,
th {
padding: 0.5em 1em;
border: 2px solid black;
}
.theadfixed th {
position: sticky;
top: 0;
text-align: center;
border: 2px solid black;
background-color: green;
}
.theadfixed th::before {
content: '';
position: absolute;
height: 2px;
width: 100%;
top: -1px;
left: 0;
background-color: black;
}
.theadfixed th::after {
content: '';
position: absolute;
height: 1px;
width: 100%;
bottom: 0;
left: 0;
background-color: black;
}
</style>
</head>
<body>
<table>
<thead class='theadfixed'>
<tr>
<th> Length </th>
<th> Width </th>
</tr>
</thead>
<tbody>
<tr>
<td>654</td>
<td>1</td>
</tr>
<tr>
<td>256</td>
<td>2</td>
</tr>
<tr>
<td>78</td>
<td>3</td>
</tr>
<tr>
<td>654</td>
<td>4</td>
</tr>
<tr>
<td>654</td>
<td>5</td>
</tr>
<tr>
<td>256</td>
<td>6</td>
</tr>
<tr>
<td>78</td>
<td>7</td>
</tr>
<tr>
<td>654</td>
<td>8</td>
</tr>
<tr>
<td>654</td>
<td>9</td>
</tr>
<tr>
<td>256</td>
<td>10</td>
</tr>
<tr>
<td>78</td>
<td>11</td>
</tr>
<tr>
<td>654</td>
<td>12</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>13</td>
</tr>
<tr>
<td>256</td>
<td>14</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
<tr>
<td>654</td>
<td>16</td>
</tr>
<tr>
<td>78</td>
<td>15</td>
</tr>
</tbody>
</table>
</body>
</html>
I'm looking to structure the tables in this way:
I tried doing that but I don't know how to put two columns inside a row (inch, cm)
It's a clothing store of a friend so I'd appreciate any help in this.
Did you try to do like this?
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
text-align:center;
}
.title{
background-color:red;
}
.sub-title{
background-color:lightgreen;
}
.footer{
background-color:lightcoral;
}
<table>
<thead>
<tr class="title">
<th colspan="7">Size Table</th>
</tr>
<tr class="sub-title">
<th rowspan="2"></th>
<th colspan="2">Bust</th>
<th colspan="2">Bust</th>
<th colspan="2">Bust</th>
</tr>
<tr class="sub-title">
<th>CH</th>
<th>CM</th>
<th>CH</th>
<th>CM</th>
<th>CH</th>
<th>CM</th>
</tr>
</thead>
<tbody>
<tr>
<td>S</td>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>Col4</td>
<td>Col5</td>
<td>Col6</td>
</tr>
<tr>
<td>M</td>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>Col4</td>
<td>Col5</td>
<td>Col6</td>
</tr>
<tr>
<td>L</td>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>Col4</td>
<td>Col5</td>
<td>Col6</td>
</tr>
</tbody>
<tfoot>
<tr class="footer">
<th colspan="7">description</th>
</tr>
</tfoot>
</table>
this code will help you. check the below jsfiddle link
https://jsfiddle.net/Gurmatpal/aq9Laaew/221894/
Check This Code. I think this will help you
table {
empty-cells: show;
border: 1px solid #000;
}
table td,
table th {
min-width: 2em;
min-height: 2em;
border: 1px solid #000;
}
<table>
<thead>
<tr>
<th rowspan="2"></th>
<th colspan="2"> </th>
<th colspan="2"> </th>
</tr>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>
I do not understand how to use the two pseudo-classes. I want to change the black background to the row with cells 3,3,3.
tbody tr:not(:empty):first-of-type td {
background: black;
}
<table>
<tr>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
</tr>
</table>
Why is background not applicable?
Cells "3" are in the second to last row. To select that second to last row, you should use :nth-last-child() as in:
edit2: <nope tbody is created as an anonymous element by browsers so you can selecttbody somethingwithout any tbody in a table> As stated by #Esko in a comment to your question, you don't have a tbody element in your HTML code. You should then remove it from the selector. tr can only be found in a table so it's unnecessary to add table to the left of your selector (but you can).</nope>
Note 1: none of your tr is/are empty: they contain whitespace and thus are non-empty.
<tr></tr> and <tr><!-- some comment --></tr>: both empty
<tr> </tr>: NOT empty
Note 2: :first-of-type would, in your code select the very first tr, which is the one with no td inside (if it had td children, it'd still be the first of its type)
tr:nth-last-child(2) td {
background:black;
}
<table>
<tr>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
</tr>
</table>
I am styling table for my website. I want to have a table where first TR doesn't have border while others TR and their TD's have a border.
Code: http://jsfiddle.net/azq6xfnr/ or here:
.table2 {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
.table2 .header {
background-color: #d8ff93;
color: #126f06;
border: 0;
}
.table2 td {
border: 1px solid #53f673;
padding: 10px;
}
.table2 tr:not(.header):nth-child(odd) {
background-color: #3cde53;
}
<table class="table2">
<tr class="header">
<td>Lp.</td>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr>
<td>1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<td>2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<td>3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<td>4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
<tr>
<td>5</td>
<td>Row 5</td>
<td>Row 5</td>
</tr>
</table>
Use the CSS first-child selector. Here is a fiddle http://jsfiddle.net/r8p061hs/ or http://jsfiddle.net/r8p061hs/1/
.table2 {
border: 1px solid black;
border-collapse: collapse;
text-align: center;
}
.table2 .header {
background-color: #d8ff93;
color: #126f06;
border: 0;
}
.table2 td {
border: 1px solid #53f673;
padding: 10px;
}
.table2 tr:not(.header):nth-child(odd) {
background-color: #3cde53;
}
.table2 tr:first-child {
border: 1px solid #53f673;
}
.table2 tr:first-child td {
border: none;
}
<table class="table2">
<tr class="header">
<td>Lp.</td>
<td>Column 1</td>
<td>Column 2</td>
</tr>
<tr>
<td>1</td>
<td>Row 1</td>
<td>Row 1</td>
</tr>
<tr>
<td>2</td>
<td>Row 2</td>
<td>Row 2</td>
</tr>
<tr>
<td>3</td>
<td>Row 3</td>
<td>Row 3</td>
</tr>
<tr>
<td>4</td>
<td>Row 4</td>
<td>Row 4</td>
</tr>
<tr>
<td>5</td>
<td>Row 5</td>
<td>Row 5</td>
</tr>
</table>
I think css pseudo class :first-child could help you: http://www.w3schools.com/cssref/sel_firstchild.asp
You need to remove the border from both your table, and the cells in the .header row, no need to use :first-child or :first-of-type as you've given the row the class header
Demo Fiddle
.table2 {
border-collapse: collapse;
border-spacing:0;
text-align: center;
/* remove the border from here */
}
.table2 .header td{
border:none; /* and from here */
}
As an alternative to the other answers, if your intention is that the first row be styled this way to be a header row, you could also consider using the more semantic <thead> grouping with <th> elements, if that's practical. You could then class them (advisable) or just rely on the tag names (less advisable due to selector performance, but still possible).
By then grouping subsequent rows within a <tbody>, you could also simplify your alternate row colouring selector, as you would be able to avoid the :not pseudo-selector.
Example of adjusted code:
<table class="table2">
<thead class="header">
<tr><th>Lp.</th><th>Column 1</th><th>Column 2</th></tr>
</thead>
<tbody>
<tr><td>1</td><td>Row 1</td><td>Row 1</td></tr>
<tr><td>2</td><td>Row 2</td><td>Row 2</td></tr>
<tr><td>3</td><td>Row 3</td><td>Row 3</td></tr>
<tr><td>4</td><td>Row 4</td><td>Row 4</td></tr>
<tr><td>5</td><td>Row 5</td><td>Row 5</td></tr>
</tbody>
</table>
Is it possible to apply a style to a column? for example lets say I want the 2nd column to be red (in reality it'd be more complicated). Below/this demo I gave the 2nd column the class b but I have no idea how to make the 2nd column of every row red. I only know how to style the header
.b { color: red; }
<table>
<th>a</th>
<th class="b">b</th>
<th>a</th>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
http://jsfiddle.net/EEJfc/3/
Use nth-child selector.
In your case
table td:nth-child(2) { color: red }
Use nth-child
tbody tr td:nth-child(2){color: red;}
Demo JsFiddle