Monday, October 14, 2019

How to change body background in HTML

How To Change Body Background In HTML




To set the background color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <body> tag, with the CSS property background-color. HTML5 do not support the <body> tag bgcolor attribute, so the CSS style is used to add background color. The bgcolor attribute deprecated in HTML5
To change body background in HTML use following code...

code :

<html>
<head>
<title>Sample</title>
</head>
<body style="background-color:green;">
<h1> Backround is green.</h1>
</body>
</html>

output :




All major browsers support the <body bgcolor> attribute.
Note:
  • HTML 5 does not support the <body bgcolor> attribute. Use CSS for this purpose. How? By using the following code: <body style="background-color: color"> Of course, you can also do it in a separate document instead of an inline method.
  • Do not use RGB value in <body bgcolor> attribute because rgb() is for CSS only, that is, it will not work in HTML.

Yash Talaiche

Author & Editor

Yash Talaiche , Python Developer |PHP|CSS|HTML|SQL|DJANGO|AUTONATION , Working on Django and Flask

0 comments:

Post a Comment