Hey all,
I've just finished banging my head against the keyboard dealing with a CSS issue. I fixed the problem, but hoping someone could explain why this happens..
Basic GistTying to get table borders to show on outside of table and table cells
My method was to simply define a id in an external style sheet and then call the id from a div. Here's the def:
#shopping_cart table {
color:#1E1816;
border: 1px solid red;
border-collapse: collapse;
border-spacing:2px;
background-color: white;
text-align: center;
margin: 5px;
padding :5px;
width:100%;
}
- #shopping_cart table {
- color:#1E1816;
- border: 1px solid red;
- border-collapse: collapse;
- border-spacing:2px;
- background-color: white;
- text-align: center;
- margin: 5px;
- padding :5px;
- width:100%;
- }
One would think that by defining the border above that you would get a border around the table and each cells. Unfortunatley, all I kept getting was a border around the table. I tried several different things, but nothing seemed to work until...
I set the border=1 in the table element:
For some reason, that did it. Of course, this kinda' breaks the CSS philosophy of keeping layout and content separate. Oddly enough, even the CSS tutorial on border-collapse on the w3c school website defines the table border. Here's my final code:
<div id="shopping_cart"><table border="1"> ..etc, etc, etc
The point is that I had to define the border property in the table element, which either I'm doing something wrong (which is highly possible) or I'm crazy.
Anyone shed some light on this please? I'm dying to know what the deal is.
THanks..
Moderator Remark: Added [code] tags