Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS Borders

Status
Not open for further replies.

foxymorons

Technical User
Aug 3, 2004
27
AU
Looking for a simple CSS style, that will give me thin table borders.

Tried every tutorial online and nothing.

any help greaT!
 
Code:
table { border:1px solid #000; }

Put that in a stylesheet, it creates a 1 pixel black border around any table used in the document.
If you want borders around the table cells you will need to add something like..

Code:
td { border:1px solid #000; }

Now you will notice a drawback with this in that since each cell has a 1 pixel border, where they touch the border is 2 pixels.
Depending on what you require in the finished thing you can apply borders to only certain sides.

Code:
table {
    border-left:1px solid #000;
    border-bottom:1px solid #000;
    border-collapse: collapse;
}

td {
    border-top:1px solid #000;
    border-right:1px solid #000;
    padding:4px;
}

You will also notice that I have added border-collapse: collapse to the table style declaration. This closes up the gaps that may be rendered between each cell and the border of the table.
As as safety net, though I am not sure how needed this is, I also remove cellspacing, cellpadding and border from the HTML table tag, like so:

Code:
<table border="0" cellspacing="0" cellpadding="0>
...

Foamcow Heavy Industries - Web design and ranting
Toccoa Games - Day of Defeat gaming community
Target Marketing Communications - Advertising, Direct Marketing and Public Relations
"I'm making time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top