Although I usually prefer HTML tables for their ease and speed, I am attempting to follow best practices and use CSS tables instead.
A new issue has arisen...
I am working on an HTML page with tabular data in CSS format, containing 3-4 pieces of data across multiple rows.
The challenge is aligning Data 4 of Row 1 vertically with Data 4 of Row 2 - a seemingly simple task.
However, upon setting the border to 1px and seeing the columns displayed, it becomes apparent that they are not perfectly aligned.
In Row 2, Data 1 lines up with Data 1 from the previous row. Yet, it also extends halfway below Data 2 of Row 2, while Data 2 falls directly below Data 2 and 3 of the prior row.
Could there be a missing piece of CSS code?
CSS guidelines:
.table { display: table; border: 1px solid black; }
.row { display: table-row; border: 1px solid black; }
.cell { display: table-cell; border: 1px solid black; }
HTML setup:
<div id="table" style="width=100%; margin: auto;">
<div class="row">
<span class="cell" style="float:left; padding: 10px;"><a href='/view/2'> Kitten Inn</a></span>
<span class="cell" style="float:left; padding: 10px;"> Wellington</span>
</div>
<div class="row">
<span class="cell" style="float:left; padding: 10px;"><a href='/view/1'> Kiwi Birdlife Park</a></span>
<span class="cell" style="float:left; padding: 10px;"> Otago</span>
</div>
</div>
Website URL: