Click here to Skip to main content
16,009,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am not able to use css on tr tag i have declared .name class for tr tag but it is not making any change on the row, please provide some solution that how to use css on tr
<style>
XML
table.gridtable td {
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #666666;
    background-color: #ffffff;
}

table.gridtable tr.name {
    background-color: #999999;
        border-width: 1px;

}

</style>
</head>
<body>

<table class="gridtable">
<tr>
    <th>Info Header 1</th><th>Info Header 2</th><th>Info Header 3</th>
</tr>
<tr>
    <td>Text 1A</td><td>Text 1B</td><td>Text 1C</td>
</tr>
<tr>
    <td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
<tr class="name">
    <td>Test on tr.name Class</td><td>Text32B</td><td>Text 3C</td>
</tr>
Posted

that is because all the td has follow this:
table.gridtable td 

You have to specify the td in the last tr by adding a td after the tr.name
table.gridtable tr.name td {
 
Share this answer
 
Comments
shiv7 7-Apr-14 7:07am    
Thanks a lot
table.gridtable tr.name td {
is working
Peter Leow 7-Apr-14 7:42am    
You are welcome.
since you set background color for the table, it might not be overriding that style for the row. try using !important for the tr row class
HTML
table.gridtable tr.name {
    background-color: #999999 !important;
        border-width: 1px;
 
}


else try this
HTML
<table class = "table">
  <tr >
    <td>red</td>
  </tr>
  <tr>
    <td>red</td>
  </tr>
  <tr class="blue">
    <td>blue</td>
  </tr>
  <tr>
    <td>blue</td>
  </tr>
</table>

JavaScript
.blue {
    background-color: blue;
}
.table
{
    background-color: orange;
}
}
 
Share this answer
 
v2
Comments
shiv7 7-Apr-14 6:54am    
Had used already but did not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900