Two ways to implement a thin border in a Web page

Source: Internet
Author: User
Tags define definition implement
Many friends have had the experience of making Web pages, and today, many Web pages are designed to use the table. This is not only conducive to the maintenance of Web pages, at the same time, improve the viewing of the Web page. In many web design styles, the thin border method is essential. Here, I'll briefly talk about how to make a thin border.
When it comes to thin borders, I think there are roughly two ways to make them, the first is to use a nested table, and the second is to use CSS to enforce the definition.

How do I nest in a table? As we all know, with bgcolor, you can define the background color of the table in the table, and use cellspacing to control the extra space of the table cell, if you define two tables, set one of the table backgrounds to all Black, and then nest in this table to define another table with the background set to all white, and put weight=100%. At this point, the two tables overlap, but if the table with black background is defined as a cellspacing=1. So that means the black table has a pixel outer space than the white one, and the white table is on the black table, which results in a thin border. The source code is as follows:
<table border= "0" cellpadding=0 cellspacing=1 bgcolor=black>
<tr>
<td>
<table width= "100%" border= "0" cellpadding=0 cellspacing=0 bgcolor=white>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>

The second is simpler, which is to force definitions with CSS (cascading style sheets), but some older browsers do not support CSS, which may result in a failure to display the desired effect. However, using CSS definition, the statement is very concise, the capacity of the Web page is also small. It is operated by defining the style= "Border-postion:black 1px solid in the 〈td〉 tag of the corresponding smallest unit at the outermost table, where the postion parameter has left, right, top, and bottom. Represents a solid line of 1 pixels wide at the left, right, top, and bottom of the cell.
<table border= "0" bgcolor=white>
<tr>
&LT;TD style= "Border-left:black 1px solid; Border-top:black 1px solid; " >
</td>
&LT;TD style= "Border-top:black 1px solid; Border-right:black 1px solid; " >
</td>
</tr>
<tr>
&LT;TD style= "Border-left:black 1px solid; Border-bottom:black 1px solid; " >
</td>
&LT;TD style= "Border-bottom:black 1px solid; Border-right:black 1px solid; " >
</td>
</tr>
</table>

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.