954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to add a border to a table row?

Hi,
I understand that it isn't possible to add a border to a . I've been reading suggestions to add the border to the instead. My problem is that I have a 2 column table and applying the border to leaves a tiny gap between the border. Is there a way to fix this?

kimmi_baby
Light Poster
40 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

To prevent the gap, remove cellspacing from the table (or set it to 0).

simplypixie
Posting Pro in Training
447 posts since Oct 2010
Reputation Points: 116
Solved Threads: 82
 

By default TR is an inline element. Here is a KLUDGE to fix your problem:

<style type='text/css'>
    th, tr  { display:inline-block }
    table   {width:352px; margin:2em auto; }
    
    th  {border: double #090; border-width: 4px 0 0 0}
    
    tr  {border: dotted 2px #f00; border-width: 0 3px 3px 3px;}
    
    th, td {width:88px; text-align:center}
  </style>  
</head>
<body>
    
<table>
  <tr>
    <th>tom</th>
    <th>dick</th>
    <th>harry</th>
  </tr>

  <tr>
    <td>tom</td>
    <td>dick</td>
    <td>harry</td>
  </tr> 

  <tr>
    <td>tom</td>
    <td>dick</td>
    <td>harry</td>
  </tr> 
</table>
John_Betong
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: