Have you ever tried to add borders to individual cells in an HTML table using style sheets? Something similar to <table border="1"> only done with CSS.
I had a requirement to put a 1 pixel black border between all cells in an HTML table. I wanted to do this without having to put a style or class attribute into every cell in the table. I thought: "How hard can this be?". There has to be a way of doing this with a single style attribute.
But after a quick search on the web with too many non-relevant results, (I mean what can you search for that doesn't bring back over a million hits). I decided to come up with my own technique:
<style type="text/css">
table.border tr td, table.border tr th {border:1px solid black;}
table.border {border-collapse:collapse;}
</style>
<table class="border">
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
<th>Header 4</th>
</tr>
<td>Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
<td>Data 4</td>
</table>
Yields the following output:
Is there a better way of doing this?
Bo Durban
Remember Me
© Copyright 2009 Moxie Data, Inc. newtelligence dasBlog 1.9.6264.0 | Page rendered at Tuesday, January 06, 2009 6:43:04 PM (Eastern Standard Time, UTC-05:00)