Several methods for creating a 1px border table

Source: Internet
Author: User


Several methods for creating a 1px border table

 

Generally, when the border of a table is defined as 1px, that is, border = 1, which is actually 2px. In most cases, we need a table with a real border of 1 px. The following describes several methods.

1. Use nested tables
Nested in two tables, the length and width of the outer table are 2 PX more than that of the internal layer, and the alignment attribute is set to horizontal center and vertical center, set the background of the outer table to the border color you need, and set the background of the inner table to the same as that of the webpage. The example is as follows:

<Table cellspacing = "1" cellpadding = "0" bgcolor = "#000000" width = "32" Height = "32" border = "0">
<Tr>
<TD align = "center">
<Table cellspacing = "0" cellpadding = "0" bgcolor = "# ffffff" width = "30" Height = "30" border = "0">
<Tr>
<TD> </TD>
</Tr>
</TD>
</Tr>
</Table>

2. Set the bright and dark border colors
The table has two attributes: bordercolorlight and bordercolordark. Set the border of the table (Border) to 1px, the border (bordercolorlight) to the background color, and the border (bordercolordark) set the actual border color as needed. The actual column is as follows:
<Table border = "1" cellpadding = "0" cellspacing = "0" width = "32" Height = "32" bordercolorlight = "#000000" bordercolordark = "# ffffff">
<Tr>
<TD> </TD>
</Tr>
</Table>

Iii. Define with CSS (1)
CodeFormat = "border-collapse: collapse"

Example:
<Table border = "1" cellspacing = "0" width = "32" Height = "32" style = "border-collapse: collapse "bordercolor =" #000000 "cellpadding =" 0 ">
<Tr>
<TD> </TD>
</Tr>
</Table>


Iv. Define with CSS (2)
Code: Style = "border: 1px solid #000000 ;"
Example:
<Table cellspacing = "0" cellpadding = "0" border = "0" width = "32" Height = "32" style = "border: 1px solid #000000;">
<Tr>
<TD> </TD>
</Tr>
</Table>
Note: Do not set the attributes of the border, border, and border. Otherwise, the expected results will not appear.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.