HTML - 背景顏色



bgcolor 屬性用於控制 HTML 元素的背景,特別是頁面主體和表格背景。以下是使用 bgcolor 屬性與任何 HTML 標籤的語法。

<tagname bgcolor="color_value"...>

此 color_value 可以採用任何形式。

<!-- Give color name -->
<table bgcolor="lime" >
 
<!-- Give hex value -->
<table bgcolor="#f1f1f1" >
 
<!-- Give color value in RGB terms -->
<table bgcolor="rgb(0,0,120)" >
 

示例

以下是設定 HTML 標籤背景的示例。

<!-- Give color name -->
<table bgcolor="yellow" width="100%" >
   <tr><td>
      This background is yellow
   </td></tr>
</table>
 
<!-- Give hex value -->
<table bgcolor="#6666FF" width="100%" >
   <tr><td>
      This background is sky blue
   </td></tr>
</table>
 
<!-- Give color value in RGB terms -->
<table bgcolor="rgb(0,0,255)"  width="100%" >
   <tr><td>
      This background is blue
   </td></tr>
</table>

這將產生以下結果

此背景為黃色
此背景為天藍色
此背景為藍色
html_backgrounds.htm
廣告