+ 1
Can anyone please tell me how to change the background colour in html ???
5 Respostas
+ 5
@Aswini wrote:
<< simply we can use 'bgcolor' >>
Simply we must not ^^
Because 'bgcolor' attribute is deprecated in Html5, as almost of styling attributes which are intended to be replaced by Css styling...
However, Html is permissive and browsers are expected to correct bad syntax as well as they can (so implicitly, html 'bgcolor' attribute is corrected by being auto replaced by 'background-color' Css property ;) ). But it's strongly recommended to no more use html attributes for styling elements ^^
Anyway, 'background-color' can be shortened by 'background', since you define other background family Css properties wich will be overwrite by 'background' shorthand since they are declared before or with css selector with mor priority weight :P
https://developer.mozilla.org/en-US/docs/Web/CSS/background?v=example
+ 4
With CSS. It can be applied to an element inline using the style attribute, but a seperate CSS file is much preferred.
Here is it inline:i99
<html>
<head>
</head>
<body style="background-color:#FFFFFF">
<div>Content</div>
</body>
</hyml>
And this is a stylesheet:
body {
background-color: #FFFFFF;
}
I recommend learning the basics of CSS so you do not need to ask a quetion about every attribute.
+ 2
In CSS:
body{
background-color: white;
}
Can change white to any other color or color code
+ 2
simply we can use 'bgcolor'
+ 1
background-color as you requested.....
p {
background-color: red;
}