如何在HTML中显示元素的背景颜色?
使用 HTML 中的bgcolor属性来显示元素的背景颜色。它用于控制 HTML 元素的背景,特别是页面正文和表格背景。
注意 – HTML5 不支持此属性。
示例
您可以尝试运行以下代码来了解如何在 HTML 中实现 bgcolor 属性 –
<!DOCTYPE html>
<html>
<head>
<title>HTML Background Colors</title>
</head>
<body>
<!-- Format 1 - Use color name -->
<table bgcolor = yellow width = 100%>
<tr>
<td>
This background is yellow
</td>
</tr>
</table>
<!-- Format 2 - Use hex value -->
<table bgcolor = #6666FF width = 100%>
<tr>
<td>
This background is sky blue
</td>
</tr>
</table>
<!-- Format 3 - Use color value in RGB terms -->
<table bgcolor = rgb(255,0,255) width = 100%>
<tr>
<td>
This background is green
</td>
</tr>
</table>
</body>
</html>
以上就是如何在HTML中显示元素的背景颜色?的详细内容,更多请关注双恒网络其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。



