• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3872
  • Last Modified:

CSS for TR/TBODY border/outline

I'm trying use CSS to put a border around multiple all columns in a table row.  Neither browser allows use of the 'border' property on TR or TBODY, and while I can use 'outline' in Firefox just fine, Internet Explorer doesn't seem to support it.

I would just put a partial border on each of the cells, but I'm already using border on them to show a different color in a block uniformly inset from the cell boundary regardless of the block content.  And a div wrapping the content of the cell won't work either because neither browser seems to honor 'height' for divs (or anything but images, for that matter).

I only found the 'outline' property by seeing how Firefox accomplishes "Outline Table Cells" with the Web Developer Toolbar.  I was hoping that the IE Developer Toolbar "Select Element by Click" function would also use CSS, but this does not seem to be the case.

I've spent hours banging my head against this, and while I'd be irritated by the lost time, I'd love to find out that there really is a way to do this.

Thanks for any suggestions!
0
Mykaella
Asked:
Mykaella
  • 3
  • 3
  • 2
1 Solution
 
RickEpnetCommented:
Here is a test page that demonstrates that.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	font-family: Arial, Helvetica, sans-serif;
}
td.insidetb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.tltb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: solid;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.toptb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.trtb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: none;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.bottb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: solid;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.brtb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.bltb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: solid;
	border-left-style: solid;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.lefttb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: none;
	border-bottom-style: none;
	border-left-style: solid;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
td.righttb {
	border-right-width: 1px;
	border-left-width: 1px;
	border-top-style: none;
	border-right-style: solid;
	border-bottom-style: none;
	border-left-style: none;
	border-right-color: #666666;
	border-left-color: #666666;
	border-top-width: 1px;
	border-bottom-width: 1px;
	border-top-color: #666666;
	border-bottom-color: #666666;
}
-->
</style>
</head>
 
<body>
<p>&nbsp;</p>
<table width="500" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class="tltb">&nbsp;</td>
    <td class="toptb">&nbsp;</td>
    <td class="trtb">&nbsp;</td>
  </tr>
  <tr>
    <td class="lefttb">&nbsp;</td>
    <td class="toptb">&nbsp;</td>
    <td class="righttb">&nbsp;</td>
  </tr>
  <tr>
    <td class="lefttb">&nbsp;</td>
    <td class="bottb">&nbsp;</td>
    <td class="righttb">&nbsp;</td>
  </tr>
  <tr>
    <td class="lefttb">&nbsp;</td>
    <td>&nbsp;</td>
    <td class="righttb">&nbsp;</td>
  </tr>
  <tr>
    <td class="bltb">&nbsp;</td>
    <td class="bottb">&nbsp;</td>
    <td class="brtb">&nbsp;</td>
  </tr>
</table>
</body>
</html>

Open in new window

0
 
MykaellaAuthor Commented:
I may be missing something, but that doesn't look at all like what I'm aiming for.  So here's an example.

Note that the hard breaks after the text on the right side of the "Good Sample" are ONLY to make the display illustrate what I want.  Padding with additional line breaks is NOT a viable solution, as the number of lines on the left side is not static or predictable.
<html>
<head>
  <style type="text/css">
    .fieldset td.left {
      border: 2px groove #cccccc;
      border-right: 0;
      padding: 15px 0px 10px 20px;
    }
    .fieldset td.center {
      border: 2px groove #cccccc;
      border-left: 0;
      border-right: 0;
      padding: 15px 0px 10px 0px;
    }
    .fieldset td.right {
      border: 2px groove #cccccc;
      border-left: 0;
      padding: 15px 10px 10px 0px;
    }
    span.legend {
      background-color: white;
      position: relative;
      left: 10px;
      top: 8px;
      padding: 0px 2px;
    }
    div.grey {
      background-color: #EEEEEE;
      height: 100%;
    }
    tr.fieldset2 {
      outline: 2px groove #cccccc;
    }
    .fieldset2 td.left {
      border-color: #ffffff;
      border-style: solid;
      border-width: 14px 0px 9px 19px;
    }
    .fieldset2 td.center {
      border-color: #ffffff;
      border-style: solid;
      border-width: 14px 0px 9px 0px;
    }
    .fieldset2 td.right {
      border-color: #ffffff;
      border-style: solid;
      border-width: 14px 9px 9px 0px;
      background-color: #eeeeee;
    }
  </style>
</head>
<body>
  <table border=0 cellpadding=0 cellspacing=0 style="margin-left: 3px; width: 700px;">
    <tr>
      <td>
        <span class="legend">Good Sample</span>
      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="fieldset">
      <td class="left" valign="top">
        <div>Some<br>random<br>data.</div>
      </td>
      <td class="center">&nbsp;</td>
      <td class="right" valign="top">
        <div class="grey">This is what I want.<br>&nbsp;<br>&nbsp;</div>
      </td>
    </tr>
    <tr>
      <td>
        <span class="legend">Bad Sample</span>
      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="fieldset">
      <td class="left" valign="top">
        <div>Some<br>more<br>random<br>data.</div>
      </td>
      <td class="center">&nbsp;</td>
      <td class="right" valign="top">
        <div class="grey">This is what I get.</div>
      </td>
    </tr>
    <tr>
      <td>
        <span class="legend">Alternate Solution</span>
      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr class="fieldset2">
      <td class="left" valign="top">This<br>works<br>in<br>Firefox...</td>
      <td class="center">&nbsp;</td>
      <td class="right" valign="top">...but not in IE</td>
    </tr>
  </table>
</body>
</html>

Open in new window

0
 
qwerty021600Commented:
You can define it like this also.. which works in all the browsers
<fieldset>
        <legend> Good Sample  </legend>
        <table cellpadding="0" cellspacing="0" border="0"  width="100%">
        <tr>
        <td>
        Some<br>random<br>data.</td>
      <td class="right"><div class="grey">This is what I want.<br>&nbsp;<br>&nbsp;</div></td>
      </tr>
      </table>
        </fieldset>
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
RickEpnetCommented:
You are talking more row height than border? I do not think I am understanding what you want...
0
 
MykaellaAuthor Commented:
qwerty:  Putting them in separate tables won't work because I need the two sides to be the same width across multiple rows without forcing a static width.

RickEpnet: My primary goal is to make the grey shading on the right side fill (with a white border) the height of the row.  I initially tried to use a div with height=100%, but that didn't work in either FF or IE.  When I discovered that 'outline' worked in FF, I was aggravated to find that it didn't work in IE.

I figure I'm closer to a solution with the border idea, so I chose to ask about that.  But I'll definitely take any CSS solution that works in at least FF and IE.
0
 
qwerty021600Commented:
Either you can fix the width of the Table and the TD's which will be consistent in all the Fieldset.
Also you can give compatibility code for classes to work for both IE and FF.
0
 
RickEpnetCommented:
What are you using for a dynamic web site? PHP, CF, ASP.NET???
0
 
MykaellaAuthor Commented:
It finally dawned on me what I had to do -- make the white padding be separate cells on the top, bottom, left, and right of the "real" cells with the data in them.  The HTML is pretty atrocious, but at least I got it to do what I wanted.  :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now