How to: "Separate table rows with a line"
There are several ways to do that. Using HTML alone, you can write
<table border=1 frame=void rules=rows>
or, if you want a border above the first row and below the last row too,
<table border=1 frame=hsides rules=rows>
This is rather inflexible, though; you cannot e.g. make the lines dotted this way, or thicker than one pixel. This is why in the past people used special separator rows, consisting of nothing but some content intended to produce a line (it gets somewhat dirty, especially when you need to make rows e.g. just a few pixels high, but it’s possible).
For the most of it, people nowadays use CSS border
properties for the purpose. It’s fairly simple and cross-browser. But note that to make the lines continuous, you need to prevent spacing between cells, using either the cellspacing=0
attribute in the table
tag or the CSS rule table { border-collapse: collapse; }
. Removing such spacing may necessitate adding some padding (with CSS, preferably) inside the cells.
At the simplest, you could use
<style>
table {
border-collapse: collapse;
}
tr {
border: solid;
border-width: 1px 0;
}
</style>
This puts a border above the first row and below the last row too. To prevent that, add e.g. the following into the style sheet:
tr:first-child {
border-top: none;
}
tr:last-child {
border-bottom: none;
}
Just style the border of the rows:
table tr {
border-bottom: 1px solid black;
}
table tr:last-child {
border-bottom: none;
}
Here is a fiddle.
Edited as mentioned by @pkyeck. The second style avoids the line under the last row. Maybe you are looking for this.