温馨提示  2024年 6月我们已经停止开发者板块文章内容更新,谢谢来访。存档数据
知识 2023-08-27 25 次阅读

html5设置背景色是哪个代码

   

在html中,设置背景颜色的代码是“<element>”,style属性用于设置元素的样式,“background-color”属性用于设置元素的背景颜色。

本教程操作环境windows10系统、html5版、dell g3电脑。

html5设置背景色是哪个代码

在html中,可以利用style属性与background-color属性来设置元素的背景颜色。

style 属性规定元素的行内样式(inline style),style 属性将覆盖任何全局的样式设定,例如在 <style> 标签或在外部样式表中规定的样式。

background-color 属性设置元素的背景颜色。

background-color 属性为元素设置一种纯色。这样的颜色会填充元素的内容、内边距和边框区域,扩展到元素边框的外边界(但不包括外边距)。如果边框有透明部分(如虚线边框),会透过这些透明部分显示出背景色。

示例如下

<!doctype html><html lang=en><head> <meta charset=utf-8> <meta name=viewport content=width=device-width, initial-scale=1.0> <meta http-equiv=x-ua-compatible content=ie=edge> <title>document</title></head><body> <input type=text></body></html>

输出结果

推荐教程《html视频教程》