Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a divider to a HTML table structure

I have the following setup in MS IE8:

 <table class="my-info">
    <tbody>
        <tr>
            <td class="info-left">First name:</td>
            <td class="info-highlight">FirstName</td>
        </tr>
        <tr>
            <td class="info-left">Surname:</td>
            <td class="info-highlight">Surname</td>
        </tr>
        <tr>
            <td class="info-left">Email:</td>
            <td class="info-highlight">TheEmail</td>
        </tr>
    </tbody>
 </table>

What I am after is a means of placing like a beveled line/dashed line or just a line between the Surname and Email.

I have tried <hr /> inside a but the spacing top and bottom is too much. I want it too look neat and compact.

like image 970
tonyf Avatar asked Mar 30 '12 03:03

tonyf


People also ask

How do you add separators in HTML?

The HTML <hr> tag is used to create a horizontal line with the purpose of dividing sections of a page. Web browsers tend to style the <hr> tag a bit differently even though it always produces a horizontal line using the border property.

How do I add a horizontal line to a table in HTML?

Adding the Horizontal Line using <hr> tag: The Horizontal Rule tag (<hr>) is used for the purpose of inserting horizontal lines in the HTML document in order to separate sections of the document. It is an empty or unpaired tag that means there is no need for the closing tag.

How do I draw a line in a table in HTML?

Simply use the <hr> tag to create a horizontal line.

How do you put space between table data in HTML?

The HTML <table> cellspacing Attribute is used to specify the space between the cells. The cellspacing attribute is set in terms of pixels. Attribute Values: pixels: It sets the space between the cells in terms of pixels.


1 Answers

I'd probably do something like this. Of course, I'm a big fan of border-collapse.

.my-info {
  border-collapse: collapse;
}

.bottom-border {
  border-bottom: 1px dashed black;
}
<table class="my-info">
  <tbody>
    <tr>
      <td class="info-left">First name:</td>
      <td class="info-highlight">FirstName</td>
    </tr>
    <tr>
      <td class="info-left bottom-border">Surname:</td>
      <td class="info-highlight bottom-border">Surname</td>
    </tr>
    <tr>
      <td class="info-left">Email:</td>
      <td class="info-highlight">TheEmail</td>
    </tr>
  </tbody>
</table>

/JSFiddle/ http://jsfiddle.net/wHmyx/

like image 56
jeremysawesome Avatar answered Sep 29 '22 18:09

jeremysawesome