HTML中有關表格的基本屬性知識


表格在網頁編程中使用非常的廣泛,而且也非常的重要,下面我就將本人編程中所總結的有關表格的基本屬性整理處理。


 

 

table標簽的基本屬性如下:

border:可以的取值為1和0,1代表有邊框,0代表沒有邊框。

bordercolor:可以設置邊框的顏色,值為顏色值。

bgcolor:設置表格的背景顏色

background:設置背景圖片


 

tr:表示表格中的行標記,屬性有align:左中右三個值

td:列標記,align屬性可以設置內容的位置

th:是第一行的標題

valign屬性可以設置th和td,可以取值Top或者Bottom。

callpadding:內容與單元格邊框的間距

cellspacing:防止文本超出邊框

如果要使單元格實現跨行或者跨列功能,使用屬性colspan和rowspan.


 

實例代碼:

<body>
    <table border="1" bordercolor="red" bgcolor="#ff4646">
        <caption>表格示例</caption>
        <tr align="center">
            <th>標題1</th>
            <th>標題2</th>
            <th>標題3</th>
        </tr>
        <tr>
            <td align="left">左</td>
            <td align="center">中</td>
            <td align="right">右</td>
        </tr>
        <tr>
            <td valign="top">top</td>
            <td>center</td>
            <td valign="bottom">bottom</td>
        </tr>
    </table>
</body>

  


 

單元格跨行

 <table border="1" bordercolor="#1f1fff">
        <caption>單元格的跨行</caption>
        <tr>
            <th>姓名</th>
            <th colspan="2">電話</th>
        </tr>
        <tr>
            <td>東騰</td>
            <td>1301485237 1067225098</td>
        </tr>
    </table>

  


 

單元格跨列

   <table border="1">
        <caption>單元格跨列</caption>
        <tr>
            <th>姓名</th>
            <th>電話</th>
        </tr>
        <tr>
            <td rowspan="2">東騰</td>
            <td>1301485237</td>
        </tr>
        <tr>
            
            <td>1067225098</td>
        </tr>
    </table>

  

不足之處,還望指點!!!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM