如何在 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>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP