Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why TR not taking style?

Tags:

css

xhtml

CSS

table tr {border-bottom:1px solid #008999}

HTML

<table width="100%" cellspacing="0" cellpadding="0">
   <thead>
      <tr>
         <th scope="col">one</th>
         <th scope="col">two</th>
         <th scope="col">three</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <th scope="row">Hello</th>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
   </tbody>
</table>
like image 504
Jitendra Vyas Avatar asked Apr 08 '10 05:04

Jitendra Vyas


People also ask

Can I use TR without TD?

Yes, you need <td> . Browsers will still try to render the table if you write invalid HTML, but the rendering will be inconsistent between browsers. <th> can take the place of <td> if the cell is a header cell. It does not take the place of <tr> which is always required.

Why do we use the TR tag >?

The <tr> HTML element defines a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.

How do you set a border on TR?

Not directly: adding a border to a tr isn't allowed. But you can target the first and last cell, give those a left/right border respectively. Then on each cell put a top border and a bottom border on each td element.


3 Answers

Add:

table {     border-collapse: collapse; } 

Otherwise tr creates no single block.

Simple example:

table  {    border: 5px solid #900;    background: #fff;  }  tr  {    border: 5px solid #090;  }  td  {    background: #ccc;    padding: 5px 0;  }    table + table  {    border-collapse: collapse;  }
<table>    <tr>      <td>def</td>      <td>ault</td>    </tr>  </table>  <table>    <tr>      <td>coll</td>      <td>apse</td>    </tr>  </table>
like image 75
fuxia Avatar answered Nov 12 '22 23:11

fuxia


Try giving

table tr th {border-bottom:1px solid #008999} 

Then you can use

table { border-collapse: collapse; } table tr {border-bottom:1px solid #008999; } 

See The collapsing border model

like image 38
rahul Avatar answered Nov 13 '22 01:11

rahul


tr by definition wont take border styles. You need to apply it to the td's within it:

table tr td {border-bottom:1px solid #008999}
like image 25
sandyiit Avatar answered Nov 12 '22 23:11

sandyiit