
การสร้างตาราง HTML ใส่สี ด้วยคำสั่ง bgcolor บทความนี้แนะนำการใช้คำสั่ง bgcolor กับแท็ก table เพื่อใส่สีลงในตาราง จากตัวอย่างเป็นการใส่สี 3 สี ลงในแท็ก tr ของตาราง สามารถเขียนคำสั่งได้ดังนี้
ตัวอย่าง การสร้างตาราง HTML ใส่สี ด้วยคำสั่ง bgcolor
<table width="30%" border="1" style="color: white">
    <tr align="center" bgcolor="red">
        <td>ลำดับ</td>
        <td>ข้อมูล</td>
    </tr>
    <tr align="center" bgcolor="green">
        <td>1</td>
        <td>AAA</td>
    </tr>   
    <tr align="center" bgcolor="blue">
        <td>2</td>
        <td>BBB</td>
    </tr>    
</table>
                
การสร้างตาราง HTML ใส่สี จากตัวอย่างใช้ attribute bgcolor กำหนดสีให้ tr แถวแรกเป็นสีแดง ด้วย bgcolor="red" และ tr แถวสองเป็นสีเขียว ด้วย bgcolor="green" และสุดท้าย bgcolor="blue" ให้กับ tr แถวที่ 3