How to set background color in HTML

Let’s say we want to create a web page with background color orange, like this:

background color HTML

We can easily achieve this in HTML using CSS styles i.e creating inline, internal and external CSS. The CSS background-color property is to be used for this purpose. Following is the correct way to use the property:

Inline CSS

Internal CSS

Example

Now, we will create a web page and set background color with all other elements essential for an HTML document:

Output

HTML background color example

Example 2

Output

changing background color with CSS

Note: A good practice in CSS is to avoid Inline CSS.

Why head tag is used in HTML
How to set/change font color in HTML
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading