当前位置: 首页 > 系统教程 > 详细页面

表格的属性

时间:2016-07-16 21:23来源:未知 作者:admin

在HTML4.01中,<table>属性不赞成使用”align”和”bgcolor”。
在HTML5中,不支持<table>标签的任何属性。
宽度和高度:<table width=”宽度” height=”高度” align=”对齐方式”></table>
                            宽高单位:可以为像素(PX)也可以是百分比。
                            对齐方式:left、center、right 即左中右。不赞成使用,请使用样式取代它。
                                     如:<table border="1" width="300" height="300" align="center">
                                                        <caption>考试成绩单</caption>
                                                        <tr>
                                                        <th>姓名</th>
                                                        <th>性别</th>
                                                        <th>语文</th>
                                                        <th>数学</th>
                                                        </tr>
                                               </table>
                  
边框: <table border=”” bordercolor=””cellspacing=””cellpadding=””></table>
  • 边框宽度 <table border=”宽度”></table> 宽度单位一般为px
  • 边框颜色 <table bordercolor=”颜色”></table>
  • 内框宽度 <table cellspacing=”宽度”></table> 单元格之间的距离
  • 单元格内文字与边框间距 <table cellpadding></table>
如:<table border="1" bordercolor="red" cellspacing="10" cellpadding="10">
                  
                            <caption>考试成绩单</caption>
                            <tr>
                                     <th>姓名</th>
                                     <th>性别</th>
                                     <th>语文</th>
                                     <th>数学</th>
                            </tr>
                            <tr>
                                     <td>小花</td>
                                     <td>女</td>
                                     <td>89</td>
                                     <td>100</td>
                            </tr>
                            <tr>
                                     <td>小花</td>
                                     <td>女</td>
                                     <td>89</td>
                                     <td>100</td>
                            </tr>        
         </table>
 
背景:<table bgcolor=”背景颜色” background=”背景图片地址”>
  • 背景颜色<table bgcolor=”背景颜色”>不赞成使用,请使用样式取代它。
  • 背景图片<table background=”背景图片地址”>不赞成使用,非W3C
如: <table border="1" bgcolor="red" background="1.jpg">
                   <!--background优先于bgcolor-->
                            <caption>考试成绩单</caption>
                            <tr>
                                     <th>姓名</th>
                                     <th>性别</th>
                                     <th>语文</th>
                                     <th>数学</th>
                            </tr>
                            <tr>
                                     <td>小花</td>
                                     <td>女</td>
                                     <td>89</td>
                                     <td>100</td>
                            </tr>
                            <tr>
                                     <td>小花</td>
                                     <td>女</td>
                                     <td>89</td>
                                     <td>100</td>
                            </tr>
                  
</table>

上一篇:表头

下一篇:表格的行属性