Solved

html table cell borders

Posted on 2014-03-05
2
1,000 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now