0

I'm trying to add a table to a php page template.
The headers and cells contents show well, but the table attributes are being ignored.

This code:

<table border="1" cellspacing="10">  
<tr>
<th>Name</th><span/>
<th>Address</th>
</tr>
<tr>
<td>name_1</td>
<td>name_2</td>
</tr>
</table> 

produces the following result:

Name  Address
name_1name_2

I get no border and no spacing (the headers are bolded, I just couldn't do it here).

Does it have something to do with wordpress?
How can it be solved?

5
  • Wordpress removes some tags and attributes automatically yes, have you condidered styling your table with CSS ?
    – mike23
    Commented Jun 14, 2011 at 9:18
  • i believe it has to do with your themes css overwriting it, can you see the attributes in the source?
    – Bainternet
    Commented Jun 14, 2011 at 9:19
  • @Bainternet, I'm currently using twenty ten. Where should I look for the attributes?
    – Ash
    Commented Jun 14, 2011 at 9:52
  • @mike23, no. So styling the table with css bypasses WP?
    – Ash
    Commented Jun 14, 2011 at 9:54
  • @Ash look in the source code of the page that is generated, right click -> view source
    – Bainternet
    Commented Jun 14, 2011 at 14:06

1 Answer 1

2

Remove the border="1" attribute but leave the cellspacing. Then go into styles.css and either add your CSS selectors or modify the existing selectors. If your table is within the id="content" block, the styling is being affected by the existing selectors. The ones you will want to adjust are:

#content table {
    border: 1px solid #e7e7e7;
    margin: 0 -1px 24px 0;
    text-align: left;
    width: 100%;
}
#content tr th,
#content thead th {
    color: #888;
    font-size: 12px;
    font-weight: bold;
    line-height: 18px;
    padding: 9px 24px;
}
#content tr td {
    border-top: 1px solid #e7e7e7;
    padding: 6px 24px;
}
#content tr.odd td {
    background: #f2f7fc;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.