Solved

html table cell borders

Posted on 2014-03-05
2
1,102 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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).

617 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