Link to home
Start Free TrialLog in
Avatar of SAbboushi
SAbboushiFlag for United States of America

asked on

I want border around table, tr and td

I'm not understanding why tr behaves differently.  Why doesn't my code give a border around the rows too?  I want a border around the table, tr and td (i.e. 3 levels of borders)

NOTE: My primary objective is not a workaround but to better understand css (i.e. if a workaround is required, I want the workaround in addition to an explanation of why my original code does not work!)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>
   THE TITLE
  </title>
  <style>
table, tr, td
   {
    border: 1px solid black;
   }
   td {
   	font-size: 26px;
   	color:red;
   }
  </style>
 </head>
 <body>
  <table class="property_list">
   <tr class="property_list_row">
    <td>1</td>
    <td>1</td>
    <td>1</td>
    <td>1</td>
   </tr>
   <tr>
    <td>2</td>
    <td>2</td>
    <td>2</td>
    <td>2</td>
   </tr>  </table>
 </body>
</html>

Open in new window

Avatar of Gary
Gary
Flag of Ireland image

As the other question the TR tag does not have a css attribute of border
http://www.w3schools.com/tags/tag_tr.asp
FF and others respect it but IE does not (correctly so), so you have to use the border-collapse hack to make IE see it as a dimensionable object.
Avatar of SAbboushi

ASKER

>> the TR tag does not have a css attribute of border
But neither does the TD tag
http://www.w3schools.com/tags/tag_td.asp

So this doesn't explain to me why it works with TD but not TR
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
K thanks for your help.  So is there a way to get the 3 levels of borders?
What do you mean 3 levels?
I want a border around the table, tr and td (i.e. 3 levels of borders)
You cannot, the most you could have is 2 borders, the TR border would become the TD border.
k thanks-