Solved

html table cell borders

Posted on 2014-03-05
2
1,044 Views
Last Modified: 2014-03-05
I'm trying to create a table that has no table border, but has just internal cell borders between neighboring cells (if a cell touches the edge of the table, there is nothing displayed).

It should look like a grid with no top, left, right, or bottom border.

I seems easy to do a table with an external border and no internal grid, but I want the opposite.
0
Comment
Question by:ttitus
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39908084
Try this:
<!DOCTYPE html>
<html>
<head>
<title> EE Q_28381371 </title>
<style type="text/css">
#tbl {
  border: none;
  border-spacing: 0;
}
#tbl tr td {
  padding: 2px 4px 2px 4px;
}
#tbl tr:not(:first-child) td {
  border-top: 1px solid black;
}
#tbl tr td:not(:first-child) {
  border-left: 1px solid black;
}
</style>
</head>
<body>
<table id="tbl">
<tr><td>1.1</td><td>1.2</td><td>1.3</td></tr>
<tr><td>2.1</td><td>2.2</td><td>2.3</td></tr>
<tr><td>3.1</td><td>3.2</td><td>3.3</td></tr>
</table>
</body>
</html>

Open in new window

Alternative with double lines/extra spacing:
<style type="text/css">
#tbl {
  border: none;
  border-spacing: 2px;
}
#tbl tr td {
  padding: 2px 4px 2px 4px;
}
#tbl tr:not(:first-child) td {
  border-top: 1px solid black;
}
#tbl tr:not(:last-child) td {
  border-bottom: 1px solid black;
}
#tbl tr td:not(:first-child) {
  border-left: 1px solid black;
}
#tbl tr td:not(:last-child) {
  border-right: 1px solid black;
}
</style>

Open in new window

0
 

Author Closing Comment

by:ttitus
ID: 39908120
Exactly what I was looking for!  Very elegantly done!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question