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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving to CSS

Status
Not open for further replies.

mickywall

Programmer
Sep 2, 2002
88
0
0
GB
In my sample code I have a few tags that I would like to replace using a stylesheet, how can I can this code below?

<table width="73%" border="2" align="center" cellspacing="0" cellpadding="2" bordercolor="#6185C1" bgcolor="EEF3FB">
<tr>
<td valign="top">
 
This:
Code:
<table width="73%" border="2" align="center" cellspacing="0" cellpadding="2" bordercolor="#6185C1" bgcolor="EEF3FB">
 <tr>
     <td valign="top">
would translate into this:
Code:
<style type="text/css">
table {
  width: 73%;
  border: 2px solid #6185c1;
  border-collapse: collapse;
  margin: 0 auto;
  background: #eef3fb;
}

td {
  padding: 2px;
  vertical-align: top;
}
</style>

<table cellspacing="0">
 <tr>
  <td>
...
At the moment, there is no CSS attribute for cellspacing that would be widely supported by the browsers. You could use border-spacing, but the most used browser definitely does not support that. Also, with the most popular browser, you might have trouble centering the table with the margin property. To cater for that, wrap the table in a div with text-align: center. Also, don't forget to add text-align: left to the table in that case, to stop centering inside table.
Code:
<div style="text-align: center;">
  <table>
  ...
  </table>
</div>
 
What's the 'border-collapse: collapse;' stand for?

Thanks for your help, you have made my day.
Michael.
 
That esentially removes all cellpadding and cellspacing from the <table> tag.

It's the same as:

[tt]<table cellpadding="0" cellspacing="0" ...>[/tt]

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top