HTML中"bgcolor"与"background-color"的区别

xiaoxiao2021-02-28  100

bgcolor只是标签属性,而backgroud更多作为css的样式属性。 它们俩大多数情况下效果完全相同。但在<p>标签下效果不同。<p>不支持bgcolor属性,只能用style标签添加CSS样式。

作为table的属性而言:

<table style="background-color:red"> <tr> <td>Hello World !</td> </tr> </table>

<table bgcolor="red"> <tr> <td>Hello World !</td> </tr> </table>

效果完全相同。

作为body属性而言:

<body style="background-color:red"> <body bgcolor="red">

效果完全相同。

不过个人推荐统一用CSS样式进行控制,把style统一放到.css文件中。

background还可以定义如下属性:

background-color 规定要使用的背景颜色; background-image 规定要使用的背景图像; background-repeat 规定如何重复背景图像; background-position 指定背景图像的位置; background-attachment 规定背景图像是否固定或者随着页面的其余部分滚动;
转载请注明原文地址: https://www.6miu.com/read-77178.html

最新回复(0)