Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 35439
  • Last Modified:

CSS Table Attributes

I need to add a couple of things to my style sheet but i havent been able to figure out the css equilavant to the html
if someone could show me id appreciate:

table properties:

border="1"
bordercolor="#8FA0BA"
style="border-collapse: collapse"

and also how do you specify cell padding and cell spacing values in css

Thank You.
0
HeadAcheMike
Asked:
HeadAcheMike
  • 3
1 Solution
 
Timbo87Commented:
table {border: 1px; border-color: #8FA0BA; border-collapse: collapse;}

Padding and spacing are done with {padding: 1px; spacing: 1px;}
0
 
Timbo87Commented:
To clarify, you'd add them into the table like this:

table {border: 1px; border-color: #8FA0BA; border-collapse: collapse;padding: 1px; spacing: 1px;}

This would change all the tables on the page with that style defined. To make multiple table styles you'd do it like this:

.mytable1 {border: 1px; border-color: #8FA0BA; border-collapse: collapse;}

And use it like this:

<table class=mytable1>
<tr>
<td>
blah
</td>
</tr>
</table>

More on CSS here: http://www.w3schools.com/css
0
 
Timbo87Commented:
Oops, typo there. There is no "spacing" style but you can use padding and margins to accomplish the same thing. There are examples at the web site above.
0
 
seanpowellCommented:
These are pretty much "visually' the same, except for the minor difference caused by the lack of a cellspacing attribute in CSS:

<html>
<head>
<style>
<!--
TD.myclass         { border: solid 1px; padding:8px; }
-->
</style>
</head>
<body>
<table border="1" bordercolor="#8FA0BA" style="border-collapse:collapse" cellpadding="4" cellspacing="4" width="400">
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
  <tr>
    <td>3</td>
    <td>4</td>
  </tr>
</table>
<p><br></p>
<table style="border:1px solid #8FA0BA; border-collapse:collapse; width:400px;">
  <tr>
    <td class="myclass">1</td>
    <td class="myclass">2</td>
  </tr>
  <tr>
    <td class="myclass">3</td>
    <td class="myclass">4</td>
  </tr>
</table>
</body>
</html>
0
 
HeadAcheMikeAuthor Commented:
Thank you for all comments, much appreciated.
0

Featured Post

Technology Partners: 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
Tackle projects and never again get stuck behind a technical roadblock.
Join Now