Write A Background Color In Html?

Efe Agbontaen

Member
Registered
Joined
Sep 4, 2020
Messages
49
Points
6
If I understand correctly

HTML:
<body bgcolor="#ff0000">

<h1> BG IS RED </h1>

</body>
 

Harry P

Well-known member
Registered
Joined
Feb 3, 2015
Messages
447
Points
28
Please Tell me About " Write A Background Color In Html? " Comment Down Below
Just creating a class with css like this
.backwhite {background: #fff;}

In your html code, call it like this
<div class="backwhite">content here</div>

you can call everywhere in your webpage when you need a white background, it is more convenient than use inline html code. :)
 

S4 Hosting

Well-known member
Moderator
Hosting Provider
Joined
Mar 5, 2021
Messages
177
Points
16
As others have said, it's better to use CSS.

Either assign a class and style that or the element in your CSS file

or use inline CSS, i.e.

Code:
<div style="background-color: #ff00ff;"> Content </div>
 

MooseLucifer

Well-known member
Registered
Joined
May 20, 2016
Messages
149
Points
28
Please Tell me About " Write A Background Color In Html? " Comment Down Below
Here’s an example of how you can set the background color of an HTML page using inline CSS:

Code:
<!DOCTYPE html>
<html>
  <head>
    <style>
      body {
background-color: lightblue;
}
    </style>
  </head>
  <body>

    <h1>Hello World!</h1>

  </body>
</html>
In this example, we’re setting the background-color property of the body element to lightblue. You can change this value to any valid CSS color.
 
Latest Threads
Replies
1
Views
15
Replies
0
Views
170
Replies
1
Views
36
Replies
2
Views
80
Recommended Threads
Replies
0
Views
2,494
Replies
8
Views
55,279
Replies
21
Views
12,983
Similar Threads

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top