How To Change Body Background In HTML
code :
<html>
<head>
<title>Sample</title>
</head>
<body style="background-color:green;">
<h1> Backround is green.</h1>
</body>
</html>
output :
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 becausergb()
is for CSS only, that is, it will not work in HTML.
0 comments:
Post a Comment