如何在 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>
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP