why can't I get a border around <tr> elements?

Hi-

I can get table and td selectors to work, but not tr:

<!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>
 tr /* <----------- table, td works but not tr */
   {
    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

SAbboushiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jagadishwor DulalBraces MediaCommented:
What's about the table and td style see my example in your code below:

<!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
{
   border-collapse:collapse;
}
tr
{
   border: 1px solid #000;
}
   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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
td{
  border-top: 1px solid black;
  border-bottom: 1px solid black;
}
td:first-child{border-left:1px solid black;}
td:last-child{border-right:1px solid black;}

Open in new window

0
SAbboushiAuthor Commented:
Thanks - can you help me understand why my code didn't work?  I read about collapsing borders model, but still don't understand why it works for td but not tr...?
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

SAbboushiAuthor Commented:
sorry padas- you must have posted while I was still reading jagadishdulal's response.
0
SAbboushiAuthor Commented:
I should clarify: I'm looking to understand how css works; my objective is not really to find a workaround.  I just don't understand why tr selector/border doesn't work
0
GaryCommented:
TR does not have a property of border because it has no dimensions, it is only design tag to say this is a row of td elements
Using the border-collapse hack makes it have dimensions equal to the td's hence the border works
0
SAbboushiAuthor Commented:
Thanks GaryC123 - where would I refer to see that TR does not have a property of border and that TD and Table do?  

I'm looking on w3schools at CSS border property and HTML td, tr and table tags, but I'm not seeing this information... table tag is the only one that has a border attribute, but that is for table CELLS... confusing to me...

Maybe you can respond to my new related question here
0
GaryCommented:
http://www.w3schools.com/tags/tag_tr.asp

You'll see all attributes have now been deprecated in HTML5
0
SAbboushiAuthor Commented:
But that's also the case for table and td...
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This is the spec you probably want.  

Tables are all good in html5, just not the inline attributes you saw in html4.
0
SAbboushiAuthor Commented:
>> This is the spec you probably want.  
huh?

>> Tables are all good in html5, just not the inline attributes you saw in html4.
I believe I was not using inline attributes...?
Sorry - feeling like such a noob!
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I thought you meant tables were depreciated in html5 and my response was simply that they are alive and well....just without the inline attributes.  http://www.w3schools.com/tags/tag_table.asp

The point to your question though is there is no border around a tr.  Instead you put the border around the td or the hack that was mentioned.

You can also make tables with div's http://coboldinosaur.com/pages/Tables-Part-2.html
0
SAbboushiAuthor Commented:
k thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.