tokenpocket钱包官网注册|bgcolor

作者: tokenpocket钱包官网注册
2024-03-13 04:40:16

HTML Color Picker

HTML Color Picker

Tutorials

Exercises

Certificates

Services

Menu

Search field

×

Log in

Sign Up

+1

My W3Schools

Get Certified

Spaces

Set Goal

Get Certified

Spaces

Set Goal

My W3Schools

Tutorials

 

Exercises

 

Certificates

 

Services

 

Spaces

Get Certified

Set Goal

Logout

×

Tutorials

Tutorials filter input

×

HTML and CSS

Learn

HTML

Tutorial

Reference

Learn

CSS

Tutorial

Reference

Learn

RWD

Tutorial

Learn

Bootstrap

Overview

Learn

W3.CSS

Tutorial

Reference

Learn

Sass

Tutorial

Reference

Learn

Colors

Tutorial

Reference

Learn

Icons

Tutorial

Reference

Learn

SVG

Tutorial

Reference

Learn

Canvas

Tutorial

Reference

Learn

Graphics

Tutorial

Learn

Character Sets

Reference

Learn

How To

Tutorial

Data Analytics

Learn

AI

Tutorial

Learn

Generative AI

Tutorial

Learn

ChatGPT-3.5

Tutorial

Learn

ChatGPT-4

Tutorial

Learn

Google Bard

Tutorial

Learn

Machine Learning

Tutorial

Learn

DSA

Tutorial

Learn

Data Science

Tutorial

Learn

NumPy

Tutorial

Learn

Pandas

Tutorial

Learn

SciPy

Tutorial

Learn

Matplotlib

Tutorial

Learn

Statistics

Tutorial

Learn

Excel

Tutorial

Learn

Google Sheets

Tutorial

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

JavaScript

Learn

JavaScript

Tutorial

Reference

Learn

React

Tutorial

Learn

jQuery

Tutorial

Reference

Learn

Vue

Tutorial

Reference

Learn

AngularJS

Tutorial

Reference

Learn

JSON

Tutorial

Reference

Learn

AJAX

Tutorial

Learn

AppML

Tutorial

Reference

Learn

W3.JS

Tutorial

Reference

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

Backend

Learn

Python

Tutorial

Reference

Learn

SQL

Tutorial

Reference

Learn

MySQL

Tutorial

Reference

Learn

PHP

Tutorial

Reference

Learn

Java

Tutorial

Reference

Learn

C

Tutorial

Learn

C++

Tutorial

Learn

C#

Tutorial

Learn

R

Tutorial

Learn

Kotlin

Tutorial

Learn

Go

Tutorial

Learn

Django

Tutorial

Reference

Learn

PostgreSQL

Tutorial

Learn

TypeScript

Tutorial

Learn

ASP

Tutorial

Reference

Learn

Node.js

Tutorial

Reference

Learn

Raspberry Pi

Tutorial

Learn

Git

Tutorial

Learn

MongoDB

Tutorial

Learn

AWS Cloud

Tutorial

Learn

XML

Tutorial

Reference

Data Analytics

Learn

AI

Tutorial

Learn

Generative AI

Tutorial

Learn

ChatGPT-3.5

Tutorial

Learn

ChatGPT-4

Tutorial

Learn

Google Bard

Tutorial

Learn

Machine Learning

Tutorial

Learn

DSA

Tutorial

Learn

Data Science

Tutorial

Learn

NumPy

Tutorial

Learn

Pandas

Tutorial

Learn

SciPy

Tutorial

Learn

Matplotlib

Tutorial

Learn

Statistics

Tutorial

Learn

Excel

Tutorial

Learn

Google Sheets

Tutorial

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

×

Exercises

Excercises filter input

×

HTML and CSS

HTML

Exercise

Quiz

CSS

Exercise

Quiz

Bootstrap

Exercise

Quiz

Data Analytics

DSA

Exercise

Quiz

NumPy

Exercise

Quiz

Pandas

Exercise

Quiz

SciPy

Exercise

Quiz

Excel

Exercise

What is an Exercise?

What is a Quiz?

JavaScript

JavaScript

Exercise

Quiz

React

Exercise

Quiz

jQuery

Exercise

Quiz

Vue

Exercise

Quiz

Backend

Python

Exercise

Quiz

SQL

Exercise

Quiz

MySQL

Exercise

Quiz

PHP

Exercise

Quiz

Java

Exercise

Quiz

C

Exercise

Quiz

C++

Exercise

Quiz

C#

Exercise

Quiz

R

Exercise

Quiz

Kotlin

Exercise

Quiz

Django

Exercise

Quiz

PostgreSQL

Exercise

Quiz

TypeScript

Exercise

Quiz

Git

Exercise

Quiz

Go

Exercise

MongoDB

Exercise

AWS Cloud

Exercise

Quiz

Data Analytics

DSA

Exercise

Quiz

NumPy

Exercise

Quiz

Pandas

Exercise

Quiz

SciPy

Exercise

Quiz

Excel

Exercise

What is an Exercise?

What is a Quiz?

×

Certificates

Filter field for certifications

×

HTML and CSS

HTML

Certificate

Course

CSS

Certificate

Course

Bootstrap 3

Certificate

Course

Bootstrap 4

Certificate

Course

Bootstrap 5

Certificate

Data Analytics

Data Analytics

Course

NumPy

Certificate

Course

Pandas

Certificate

Course

Excel

Certificate

Social Media

Course

What is a Certificate?

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

JavaScript

JavaScript

Certificate

Course

React

Certificate

Course

jQuery

Certificate

Course

Vue

Certificate

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

Backend

Python

Certificate

Course

SQL

Certificate

Course

MySQL

Certificate

PHP

Certificate

Course

Java

Certificate

Course

C

Certificate

C++

Certificate

Course

C#

Certificate

Course

R

Course

Django

Certificate

TypeScript

Certificate

Course

XML

Certificate

Course

Cyber Security

Certificate

Course

Accessibility

Certificate

Course

Python Apps on AWS

Course

AWS Training

Courses

Data Analytics

Data Analytics

Course

NumPy

Course

Pandas

Course

Excel

Certificate

Social Media

Course

What is a Certificate?

×

All Our Services

Services filter input

×

W3Schools offers a wide range of services and products for beginners and professionals,

helping millions of people everyday to learn and master new skills.

Free Tutorials

Enjoy our free tutorials like millions of other internet users since 1999

References

Explore our selection of references covering all popular coding languages

Create a Website

Create your own website with

W3Schools Spaces

- no setup required

Exercises

Test your skills with different exercises

Quizzes

Test yourself with multiple choice questions

Get Certified

Document your knowledge

Log in / Sign Up

Create a

free

W3Schools Account to Improve Your Learning Experience

My Learning

Track your learning progress at W3Schools and collect rewards

Upgrade

Become a PRO user and unlock powerful features (ad-free, hosting, videos,..)

Where To Start

Not sure where you want to start? Follow our guided path

Code Editor (Try it)

With our online code editor, you can edit code and view the result in your browser

Videos

Learn the basics of HTML in a fun and engaging video tutorial

Templates

We have created a bunch of responsive website templates you can use - for free!

Web Hosting

Host your own website, and share it to the world with

W3Schools Spaces

Create a Server

Create your own server using Python, PHP, React.js, Node.js, Java, C#, etc.

How To's

Large collection of code snippets for HTML, CSS and JavaScript

CSS Framework

Build fast and responsive sites using our free

W3.CSS

framework

Browser Statistics

Read long term trends of browser usage

Typing Speed

Test your typing speed

AWS Training

Learn Amazon Web Services

Color Picker

Use our color picker to find different RGB, HEX and HSL colors.

Code Game

W3Schools Coding Game! Help the lynx collect pine cones

Set Goal

Get personalized learning journey based on your current skills and goals

Newsletter

Join our newsletter and get access to exclusive content every month

×

   ❮     

HTML

CSS

JAVASCRIPT

SQL

PYTHON

JAVA

PHP

HOW TO

W3.CSS

C

C++

C#

BOOTSTRAP

REACT

MYSQL

JQUERY

EXCEL

XML

DJANGO

NUMPY

PANDAS

NODEJS

R

TYPESCRIPT

ANGULAR

GIT

POSTGRESQL

MONGODB

ASP

AI

GO

KOTLIN

SASS

VUE

DSA

GEN AI

SCIPY

AWS

CYBERSECURITY

DATA SCIENCE

     ❯   

Colors Tutorial

Colors HOME

Color Names

Color Values

Color Groups

Color Shades

Color Picker

Color Mixer

Color Converter

Color RGB

Color HEX

Color HSL

Color HWB

Color CMYK

Color NCol

Color Gradient

Color Theory

Color Wheels

Color currentcolor

Color Hues

Color Schemes

Color Palettes

Color Brands

Color W3.CSS

Color Metro UI

Color Win8

Color Flat UI

Color Psychology

Color Schemes

Colors Monochromatic

Colors Analogous

Colors Complementary

Colors Triadic

Colors Compound

Color Trends

Colors of the Year

Colors 2021

Colors 2020

Colors 2019

Colors 2018

Colors 2017

Colors 2016

Color Standards

Colors USA

Colors UK

Colors Australia

Colors RAL

Colors NBS

Colors NCS

Colors X11

Colors Crayola

Colors Resene

Colors XKCD

HTML Color Picker

❮ Previous

Next ❯

Pick a Color:

 

Or Enter a Color:

OK

Wrong Input

Or Use HTML5:

Selected Color:

Black Text

Shadow

White Text

Shadow

RGB (Red, Green, Blue)

Red

Green

Blue

❮ Previous

Next ❯

+1

 

W3schools Pathfinder

Track your progress - it's free!

 

Log in

Sign Up

COLOR PICKER

SPACES

UPGRADE

AD-FREE

NEWSLETTER

GET CERTIFIED

REPORT ERROR

×

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

help@w3schools.com

Top Tutorials

HTML Tutorial

CSS Tutorial

JavaScript Tutorial

How To Tutorial

SQL Tutorial

Python Tutorial

W3.CSS Tutorial

Bootstrap Tutorial

PHP Tutorial

Java Tutorial

C++ Tutorial

jQuery Tutorial

Top References

HTML Reference

CSS Reference

JavaScript Reference

SQL Reference

Python Reference

W3.CSS Reference

Bootstrap Reference

PHP Reference

HTML Colors

Java Reference

Angular Reference

jQuery Reference

Top Examples

HTML Examples

CSS Examples

JavaScript Examples

How To Examples

SQL Examples

Python Examples

W3.CSS Examples

Bootstrap Examples

PHP Examples

Java Examples

XML Examples

jQuery Examples

Get Certified

HTML Certificate

CSS Certificate

JavaScript Certificate

Front End Certificate

SQL Certificate

Python Certificate

PHP Certificate

jQuery Certificate

Java Certificate

C++ Certificate

C# Certificate

XML Certificate

FORUM

ABOUT

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.

Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness

of all content. While using W3Schools, you agree to have read and accepted our terms of use,

cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved.

W3Schools is Powered by W3.CSS.

HTML Background Color – Change BG Color Tutorial

HTML Background Color – Change BG Color Tutorial

Search

Submit your search query

Forum

Donate

September 12, 2022

/

#HTML

HTML Background Color – Change BG Color Tutorial

Joel Olawanle

When you're building web pages, you always want to create unique layouts. You want your web page to be appealing to your users and not jarring to the eye.

And to help do that, you can choose background and text colors that blend well and complement each other.

By default, you will notice that your web page has a transparent background color, which you can change to any color you want.

For example, you might want to create a dark mode feature on your web page so that the background has a dark color while the text has a light color. This help readers avoid harsh colors that can affect their eyes.

In this article, you will learn how to change the background color of your web pages with HTML and CSS.

How We Used to Change Background Color

In the past, before the introduction of HTML5, some basic styling was handled by HTML.

For example, when you wanted to change the background color of your page, you could've easily added the bgcolor attribute in the opening body tag and set it to the value of your preferred color. This could be its hex code or the name.

// Or

However, this attribute was depreciated when HTML5 was introduced. It’s now replaced by a better alternative, the CSS background-color property. This makes sense because HTML is a markup language, not a styling language. When dealing with styling, it is best to use CSS.

In case you are in a rush to see how you can change the background color of your web page, divs, and other elements, then here it is:

// Using inline CSS

// ...

// Using internal/external CSS

selector {

background-color: value;

}

Let's say you have time to spare. Let's quickly get started.

How to Change Background Color in HTML

You can use the CSS background-color property to change the color of your web pages. This property works like every other CSS property, meaning you can make use of it to style your page in three ways:

within your HTML tags (inline styling),

within a style tag in the head tag (internal styling),

or in a dedicated CSS file (external styling).

Depending on your preference, you will set the background-color property to a color name, a hex code, an RGB value, or even an HSL value. You can use this property to style not only the body of your web page but also divs, headings, tables and lots more.

Check out the following example in CodePen:

See the Pen

Background-color by Olawanle Joel (@olawanlejoel)

on CodePen.

How to Change Background Color in HTML With Inline CSS

Inline CSS allows you to apply styles directly to your HTML elements. This means you are putting CSS into an HTML tag directly. You do this with the style attribute, which holds all the styles you wish to apply to your HTML tag.

// ...

You will use the CSS background-color property alongside your preferred color value:

// Color Name Value

// Hex Value

// RGB Value

// ...

// HSL Value

// ...

How to Change Background Color in HTML With Internal/External CSS

The best way to style web pages is external styling, but you can always use internal styling when you only have a few lines of styles.

Both internal and external make use of the same approach: they both use selectors to add styling to HTML elements.

For internal styling, all styles are added to your HTML file within the

// ...

For external styling, all you have to do is add the CSS styling to your CSS file using the general syntax:

selector {

background-color: value;

}

The selector can either be your HTML tag or maybe a class or an ID. For example:

// HTML

Welcome to freeCodeCamp!

// CSS

div {

background-color: skyblue;

}

Or you could use a class:

// HTML

Welcome to freeCodeCamp!

// CSS

.container {

background-color: skyblue;

}

Or you could use an id:

// HTML

Welcome to freeCodeCamp!

// CSS

#container {

background-color: skyblue;

}

Note: As you have seen earlier, with inline CSS, you can use the color name, Hex code, RGB value, and HSL value with both internal or external styling.

Wrapping Up

In this article, you have learned how to change the background color of HTML element’s using the CSS background-color property. You also learned how developers did it before the introduction of HTML5 with the bgcolor attribute.

It is essential to remember that styling your HTML elements with internal or external is always preferable to inline styling because it provides more flexibility. For example, instead of adding similar inline styles to all your

tag elements, you can use a single CSS class for them.

Inline styles are not considered best practices because they result in a lot of repetition - you cannot reuse the styles elsewhere. To learn more, you can read my article on Inline Style in HTML. You can also learn how to change text size in this article, and how to change text color in this article.

I hope this tutorial gives you the knowledge to change the color of your HTML text to make it look better.

Have fun coding!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Joel Olawanle

Frontend Developer & Technical Writer

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTISEMENT

freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546)

Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public.

Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.

You can make a tax-deductible donation here.

Trending Guides

Delete File in Linux

What is :: in Python?

Python PWD Equivalent

JSONObject.toString()

What is SSH in Linux?

Max int Size in Python

Python Bytes to String

Git Pull Remote Branch

Fix Git Merge Conflicts

JavaScript Refresh Page

Git Revert

JSON Comments

Java Use Cases

Python Copy File

Linux cp Command

Python list.pop()

JS Sum of an Array

Python Split String

HTTP Request Methods

Compare Strings in C

What Does $ Mean in JS?

Python range() Function

Pandas Iterate Over Rows

Initialize a List in Java

Check for Empty String JS

Initialize ArrayList Java

Delete Environment in Conda

Pretty Print JSON in Python

What Does $ Mean in Python?

Check for Empty List Python

Mobile App

Our Charity

About

Alumni Network

Open Source

Shop

Support

Sponsors

Academic Honesty

Code of Conduct

Privacy Policy

Terms of Service

Copyright Policy

CSS background-color property

CSS background-color property

Tutorials

Exercises

Certificates

Services

Menu

Search field

×

Log in

Sign Up

+1

My W3Schools

Get Certified

Spaces

Set Goal

Get Certified

Spaces

Set Goal

My W3Schools

Tutorials

 

Exercises

 

Certificates

 

Services

 

Spaces

Get Certified

Set Goal

Logout

×

Tutorials

Tutorials filter input

×

HTML and CSS

Learn

HTML

Tutorial

Reference

Learn

CSS

Tutorial

Reference

Learn

RWD

Tutorial

Learn

Bootstrap

Overview

Learn

W3.CSS

Tutorial

Reference

Learn

Sass

Tutorial

Reference

Learn

Colors

Tutorial

Reference

Learn

Icons

Tutorial

Reference

Learn

SVG

Tutorial

Reference

Learn

Canvas

Tutorial

Reference

Learn

Graphics

Tutorial

Learn

Character Sets

Reference

Learn

How To

Tutorial

Data Analytics

Learn

AI

Tutorial

Learn

Generative AI

Tutorial

Learn

ChatGPT-3.5

Tutorial

Learn

ChatGPT-4

Tutorial

Learn

Google Bard

Tutorial

Learn

Machine Learning

Tutorial

Learn

DSA

Tutorial

Learn

Data Science

Tutorial

Learn

NumPy

Tutorial

Learn

Pandas

Tutorial

Learn

SciPy

Tutorial

Learn

Matplotlib

Tutorial

Learn

Statistics

Tutorial

Learn

Excel

Tutorial

Learn

Google Sheets

Tutorial

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

JavaScript

Learn

JavaScript

Tutorial

Reference

Learn

React

Tutorial

Learn

jQuery

Tutorial

Reference

Learn

Vue

Tutorial

Reference

Learn

AngularJS

Tutorial

Reference

Learn

JSON

Tutorial

Reference

Learn

AJAX

Tutorial

Learn

AppML

Tutorial

Reference

Learn

W3.JS

Tutorial

Reference

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

Backend

Learn

Python

Tutorial

Reference

Learn

SQL

Tutorial

Reference

Learn

MySQL

Tutorial

Reference

Learn

PHP

Tutorial

Reference

Learn

Java

Tutorial

Reference

Learn

C

Tutorial

Learn

C++

Tutorial

Learn

C#

Tutorial

Learn

R

Tutorial

Learn

Kotlin

Tutorial

Learn

Go

Tutorial

Learn

Django

Tutorial

Reference

Learn

PostgreSQL

Tutorial

Learn

TypeScript

Tutorial

Learn

ASP

Tutorial

Reference

Learn

Node.js

Tutorial

Reference

Learn

Raspberry Pi

Tutorial

Learn

Git

Tutorial

Learn

MongoDB

Tutorial

Learn

AWS Cloud

Tutorial

Learn

XML

Tutorial

Reference

Data Analytics

Learn

AI

Tutorial

Learn

Generative AI

Tutorial

Learn

ChatGPT-3.5

Tutorial

Learn

ChatGPT-4

Tutorial

Learn

Google Bard

Tutorial

Learn

Machine Learning

Tutorial

Learn

DSA

Tutorial

Learn

Data Science

Tutorial

Learn

NumPy

Tutorial

Learn

Pandas

Tutorial

Learn

SciPy

Tutorial

Learn

Matplotlib

Tutorial

Learn

Statistics

Tutorial

Learn

Excel

Tutorial

Learn

Google Sheets

Tutorial

Web Building

Create a Website

HOT!

Create a Server

NEW

Where To Start

Web Templates

Web Statistics

Web Certificates

Web Development

Code Editor

Test Your Typing Speed

Play a Code Game

Cyber Security

Accessibility

Join our Newsletter

×

Exercises

Excercises filter input

×

HTML and CSS

HTML

Exercise

Quiz

CSS

Exercise

Quiz

Bootstrap

Exercise

Quiz

Data Analytics

DSA

Exercise

Quiz

NumPy

Exercise

Quiz

Pandas

Exercise

Quiz

SciPy

Exercise

Quiz

Excel

Exercise

What is an Exercise?

What is a Quiz?

JavaScript

JavaScript

Exercise

Quiz

React

Exercise

Quiz

jQuery

Exercise

Quiz

Vue

Exercise

Quiz

Backend

Python

Exercise

Quiz

SQL

Exercise

Quiz

MySQL

Exercise

Quiz

PHP

Exercise

Quiz

Java

Exercise

Quiz

C

Exercise

Quiz

C++

Exercise

Quiz

C#

Exercise

Quiz

R

Exercise

Quiz

Kotlin

Exercise

Quiz

Django

Exercise

Quiz

PostgreSQL

Exercise

Quiz

TypeScript

Exercise

Quiz

Git

Exercise

Quiz

Go

Exercise

MongoDB

Exercise

AWS Cloud

Exercise

Quiz

Data Analytics

DSA

Exercise

Quiz

NumPy

Exercise

Quiz

Pandas

Exercise

Quiz

SciPy

Exercise

Quiz

Excel

Exercise

What is an Exercise?

What is a Quiz?

×

Certificates

Filter field for certifications

×

HTML and CSS

HTML

Certificate

Course

CSS

Certificate

Course

Bootstrap 3

Certificate

Course

Bootstrap 4

Certificate

Course

Bootstrap 5

Certificate

Data Analytics

Data Analytics

Course

NumPy

Certificate

Course

Pandas

Certificate

Course

Excel

Certificate

Social Media

Course

What is a Certificate?

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

JavaScript

JavaScript

Certificate

Course

React

Certificate

Course

jQuery

Certificate

Course

Vue

Certificate

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

Programs

Full Access

Best Value!

Front End

Certificate

Course

Web Dev.

Certificate

Course

Web App

Certificate

Course

Web Design

Certificate

Course

Backend

Python

Certificate

Course

SQL

Certificate

Course

MySQL

Certificate

PHP

Certificate

Course

Java

Certificate

Course

C

Certificate

C++

Certificate

Course

C#

Certificate

Course

R

Course

Django

Certificate

TypeScript

Certificate

Course

XML

Certificate

Course

Cyber Security

Certificate

Course

Accessibility

Certificate

Course

Python Apps on AWS

Course

AWS Training

Courses

Data Analytics

Data Analytics

Course

NumPy

Course

Pandas

Course

Excel

Certificate

Social Media

Course

What is a Certificate?

×

All Our Services

Services filter input

×

W3Schools offers a wide range of services and products for beginners and professionals,

helping millions of people everyday to learn and master new skills.

Free Tutorials

Enjoy our free tutorials like millions of other internet users since 1999

References

Explore our selection of references covering all popular coding languages

Create a Website

Create your own website with

W3Schools Spaces

- no setup required

Exercises

Test your skills with different exercises

Quizzes

Test yourself with multiple choice questions

Get Certified

Document your knowledge

Log in / Sign Up

Create a

free

W3Schools Account to Improve Your Learning Experience

My Learning

Track your learning progress at W3Schools and collect rewards

Upgrade

Become a PRO user and unlock powerful features (ad-free, hosting, videos,..)

Where To Start

Not sure where you want to start? Follow our guided path

Code Editor (Try it)

With our online code editor, you can edit code and view the result in your browser

Videos

Learn the basics of HTML in a fun and engaging video tutorial

Templates

We have created a bunch of responsive website templates you can use - for free!

Web Hosting

Host your own website, and share it to the world with

W3Schools Spaces

Create a Server

Create your own server using Python, PHP, React.js, Node.js, Java, C#, etc.

How To's

Large collection of code snippets for HTML, CSS and JavaScript

CSS Framework

Build fast and responsive sites using our free

W3.CSS

framework

Browser Statistics

Read long term trends of browser usage

Typing Speed

Test your typing speed

AWS Training

Learn Amazon Web Services

Color Picker

Use our color picker to find different RGB, HEX and HSL colors.

Code Game

W3Schools Coding Game! Help the lynx collect pine cones

Set Goal

Get personalized learning journey based on your current skills and goals

Newsletter

Join our newsletter and get access to exclusive content every month

×

   ❮   

HTML

CSS

JAVASCRIPT

SQL

PYTHON

JAVA

PHP

HOW TO

W3.CSS

C

C++

C#

BOOTSTRAP

REACT

MYSQL

JQUERY

EXCEL

XML

DJANGO

NUMPY

PANDAS

NODEJS

R

TYPESCRIPT

ANGULAR

GIT

POSTGRESQL

MONGODB

ASP

AI

GO

KOTLIN

SASS

VUE

DSA

GEN AI

SCIPY

AWS

CYBERSECURITY

DATA SCIENCE

     ❯   

CSS Reference

CSS Reference

CSS Browser Support

CSS Selectors

CSS Functions

CSS Reference Aural

CSS Web Safe Fonts

CSS Fallback Fonts

CSS Animatable

CSS Units

CSS PX-EM Converter

CSS Colors

CSS Color Values

CSS Default Values

CSS Entities

CSS Properties

accent-color

align-content

align-items

align-self

all

animation

animation-delay

animation-direction

animation-duration

animation-fill-mode

animation-iteration-count

animation-name

animation-play-state

animation-timing-function

aspect-ratio

backdrop-filter

backface-visibility

background

background-attachment

background-blend-mode

background-clip

background-color

background-image

background-origin

background-position

background-position-x

background-position-y

background-repeat

background-size

block-size

border

border-block

border-block-color

border-block-end

border-block-end-color

border-block-end-style

border-block-end-width

border-block-start

border-block-start-color

border-block-start-style

border-block-start-width

border-block-style

border-block-width

border-bottom

border-bottom-color

border-bottom-left-radius

border-bottom-right-radius

border-bottom-style

border-bottom-width

border-collapse

border-color

border-end-end-radius

border-end-start-radius

border-image

border-image-outset

border-image-repeat

border-image-slice

border-image-source

border-image-width

border-inline

border-inline-color

border-inline-end

border-inline-end-color

border-inline-end-style

border-inline-end-width

border-inline-start

border-inline-start-color

border-inline-start-style

border-inline-start-width

border-inline-style

border-inline-width

border-left

border-left-color

border-left-style

border-left-width

border-radius

border-right

border-right-color

border-right-style

border-right-width

border-spacing

border-start-end-radius

border-start-start-radius

border-style

border-top

border-top-color

border-top-left-radius

border-top-right-radius

border-top-style

border-top-width

border-width

bottom

box-decoration-break

box-reflect

box-shadow

box-sizing

break-after

break-before

break-inside

caption-side

caret-color

@charset

clear

clip

clip-path

color

column-count

column-fill

column-gap

column-rule

column-rule-color

column-rule-style

column-rule-width

column-span

column-width

columns

content

counter-increment

counter-reset

counter-set

cursor

direction

display

empty-cells

filter

flex

flex-basis

flex-direction

flex-flow

flex-grow

flex-shrink

flex-wrap

float

font

@font-face

font-family

font-feature-settings

font-kerning

font-size

font-size-adjust

font-stretch

font-style

font-variant

font-variant-caps

font-weight

gap

grid

grid-area

grid-auto-columns

grid-auto-flow

grid-auto-rows

grid-column

grid-column-end

grid-column-gap

grid-column-start

grid-gap

grid-row

grid-row-end

grid-row-gap

grid-row-start

grid-template

grid-template-areas

grid-template-columns

grid-template-rows

hanging-punctuation

height

hyphens

hyphenate-character

image-rendering

@import

inline-size

inset

inset-block

inset-block-end

inset-block-start

inset-inline

inset-inline-end

inset-inline-start

isolation

justify-content

justify-items

justify-self

@keyframes

left

letter-spacing

line-height

list-style

list-style-image

list-style-position

list-style-type

margin

margin-block

margin-block-end

margin-block-start

margin-bottom

margin-inline

margin-inline-end

margin-inline-start

margin-left

margin-right

margin-top

mask-image

mask-mode

mask-origin

mask-position

mask-repeat

mask-size

max-block-size

max-height

max-inline-size

max-width

@media

min-block-size

min-inline-size

min-height

min-width

mix-blend-mode

object-fit

object-position

offset

offset-anchor

offset-distance

offset-path

offset-rotate

opacity

order

orphans

outline

outline-color

outline-offset

outline-style

outline-width

overflow

overflow-anchor

overflow-wrap

overflow-x

overflow-y

overscroll-behavior

overscroll-behavior-block

overscroll-behavior-inline

overscroll-behavior-x

overscroll-behavior-y

padding

padding-block

padding-block-end

padding-block-start

padding-bottom

padding-inline

padding-inline-end

padding-inline-start

padding-left

padding-right

padding-top

page-break-after

page-break-before

page-break-inside

paint-order

perspective

perspective-origin

place-content

place-items

place-self

pointer-events

position

quotes

resize

right

rotate

row-gap

scale

scroll-behavior

scroll-margin

scroll-margin-block

scroll-margin-block-end

scroll-margin-block-start

scroll-margin-bottom

scroll-margin-inline

scroll-margin-inline-end

scroll-margin-inline-start

scroll-margin-left

scroll-margin-right

scroll-margin-top

scroll-padding

scroll-padding-block

scroll-padding-block-end

scroll-padding-block-start

scroll-padding-bottom

scroll-padding-inline

scroll-padding-inline-end

scroll-padding-inline-start

scroll-padding-left

scroll-padding-right

scroll-padding-top

scroll-snap-align

scroll-snap-stop

scroll-snap-type

scrollbar-color

tab-size

table-layout

text-align

text-align-last

text-decoration

text-decoration-color

text-decoration-line

text-decoration-style

text-decoration-thickness

text-emphasis

text-emphasis-color

text-emphasis-position

text-emphasis-style

text-indent

text-justify

text-orientation

text-overflow

text-shadow

text-transform

text-underline-offset

text-underline-position

top

transform

transform-origin

transform-style

transition

transition-delay

transition-duration

transition-property

transition-timing-function

translate

unicode-bidi

user-select

vertical-align

visibility

white-space

widows

width

word-break

word-spacing

word-wrap

writing-mode

z-index

CSS background-color Property

❮ Previous

Complete CSS Reference

Next ❯

Example

Set the background color for a page:

body {background-color: coral;}

Try it Yourself »

More "Try it Yourself" examples below.

Definition and Usage

The background-color property sets the background color of an element.

The background of an element is the total size of the element, including

padding and border (but not the margin).

Tip: Use a background color and a text color that makes the text easy

to read.

Show demo ❯

Default value:

transparent

Inherited:

no

Animatable:

yes. Read about animatable

Try it

Version:

CSS1

JavaScript syntax:

object.style.backgroundColor="#00FF00"

Try it

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property

background-color

1.0

4.0

1.0

1.0

3.5

CSS Syntax

background-color: color|transparent|initial|inherit;

Property Values

Value

Description

Demo

color

Specifies the background color. Look at

CSS Color Values for a complete list of possible color values.

Demo ❯

transparent

Specifies that the background color should be transparent. This is default

Demo ❯

initial

Sets this property to its default value. Read about initial

inherit

Inherits this property from its parent element. Read about inherit

More Examples

Example

Specify the background color with a HEX value:

body {background-color: #92a8d1;}

Try it Yourself »

Example

Specify the background color with an RGB value:

body {background-color: rgb(201, 76, 76);}

Try it Yourself »

Example

Specify the background color with an RGBA value:

body {background-color: rgba(201, 76, 76, 0.3);}

Try it Yourself »

Example

Specify the background color with a HSL value:

body {background-color: hsl(89, 43%, 51%);}

Try it Yourself »

Example

Specify the background color with a HSLA value:

body {background-color: hsla(89, 43%, 51%, 0.3);}

Try it Yourself »

Example

Set background colors for different elements:

body {  background-color: #fefbd8;}h1 {  background-color: #80ced6;}div {  background-color: #d5f4e6;

}span {  background-color: #f18973;}

Try it Yourself »

Related Pages

CSS tutorial: CSS Background

HTML DOM reference: backgroundColor property

❮ Previous

Complete CSS Reference

Next ❯

+1

 

W3schools Pathfinder

Track your progress - it's free!

 

Log in

Sign Up

COLOR PICKER

SPACES

UPGRADE

AD-FREE

NEWSLETTER

GET CERTIFIED

REPORT ERROR

×

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

help@w3schools.com

Top Tutorials

HTML Tutorial

CSS Tutorial

JavaScript Tutorial

How To Tutorial

SQL Tutorial

Python Tutorial

W3.CSS Tutorial

Bootstrap Tutorial

PHP Tutorial

Java Tutorial

C++ Tutorial

jQuery Tutorial

Top References

HTML Reference

CSS Reference

JavaScript Reference

SQL Reference

Python Reference

W3.CSS Reference

Bootstrap Reference

PHP Reference

HTML Colors

Java Reference

Angular Reference

jQuery Reference

Top Examples

HTML Examples

CSS Examples

JavaScript Examples

How To Examples

SQL Examples

Python Examples

W3.CSS Examples

Bootstrap Examples

PHP Examples

Java Examples

XML Examples

jQuery Examples

Get Certified

HTML Certificate

CSS Certificate

JavaScript Certificate

Front End Certificate

SQL Certificate

Python Certificate

PHP Certificate

jQuery Certificate

Java Certificate

C++ Certificate

C# Certificate

XML Certificate

FORUM

ABOUT

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.

Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness

of all content. While using W3Schools, you agree to have read and accepted our terms of use,

cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved.

W3Schools is Powered by W3.CSS.

HTML bgcolor Attribute - GeeksforGeeks

HTML bgcolor Attribute - GeeksforGeeks

Skip to content

TutorialsPython TutorialTaking Input in PythonPython OperatorsPython Data TypesPython NumbersPython StringPython ListsPython TuplesSets in PythonPython DictionaryPython Loops and Control FlowPython If ElsePython For LoopsPython While LoopsPython BreaksPython Continue StatementPython Pass StatementPython FunctionsPython OOPS ConceptPython Data StructuresPython DSALinked ListStackQueueTreeHeapHashingGraphSetsMapAdvance Data StructureSorting AlgorithmsSearching AlgorithmsPython Exception HandlingPython File HandlingPython ExercisesPython List ExercisePython String ExercisePython Tuple ExercisePython Dictionary ExercisePython Set ExercisePython Design PatternsPython Programming ExamplesPython Practice QuestionsJavaJava Programming LanguageJava TutorialData TypesVariablesOperatorsOperators in JavaArithmetic OperatorsUnary OperatorsAssignment OperatorsRelational OperatorsLogical OperatorsTernary OperatorsFlow Control in JavaFlow Controlif Statementif-else Statementif-else-if LadderContinue StatementBreak StatementReturn StatementLoops in JavaLoopsdo-while LoopFor LoopFor-each LoopMethodsStringsArraysOOPs ConceptsOOPs ConceptsClasses and ObjectsAccess ModifiersInheritanceAbstractionEncapsulationPolymorphismInterfacePackagesMultithreadingFile HandlingRegular ExpressionJava CollectionsJava CollectionsCollection ClassList InterfaceArrayListVector ClassStack ClassLinkedList ClassQueue InterfaceSet InterfaceHashSet ClassTreeSetMap InterfaceHashMap ClassHashTable ClassIteratorComparatorCollection Interview QuestionsJava 8 TutorialJava ProgramsJava Programming ExamplesJava Array ProgramsJava String ProgramsJava Date-Time ProgramsJava File Handling ProgramsJava Collection ProgramsJava JDBC ProgramsJava Apache POI ProgramsJava OpenCV ProgramsJava Interview QuestionsJava Interview QuestionsCore Java Interview Questions-FreshersJava Multithreading Interview QuestionsOOPs Interview Questions and AnswersJava ExercisesJava QuizJava QuizCore Java MCQJava ProjectsAdvance JavaSpring TutorialSpring Boot TutorialSpring Boot Interview QuestionsSpring MVC TutorialSpring MVC Interview QuestionsHibernate TutorialHibernate Interview QuestionsProgramming LanguagesCC++JavaScriptPHPR TutorialC#SQLScalaPerlGo LanguageKotlinSystem DesignSystem Design TutorialWhat is System DesignKey Terminologies in System DesignAnalysis and Architecture of SystemsScalability in System DesignDatabases in System DesignHigh Level Design or HLDLow Level Design or LLDCommunication ProtocolsWeb Servers and ProxiesCase Studies in Designing SystemsComplete System Design TutorialSoftware Design PatternsFactory PatternObserver PatternSingleton Design PatternDecorator PatternStrategy PatternAdapter PatternCommand PatternIterator PatternPrototype Design PatternAll Design PatternsSystem Design RoadmapTop 10 System Design Interview Questions and AnswersInterview CornerCompany PreparationTop TopicsPractice Company QuestionsInterview ExperiencesExperienced InterviewsInternship InterviewsCompetitive ProgrammingMultiple Choice QuizzesAptitude for PlacementsComputer Science SubjectsMathematicsOperating SystemDBMSComputer NetworksComputer Organization and ArchitectureTheory of ComputationCompiler DesignDigital LogicSoftware EngineeringDevOpsGITAWSDockerKubernetesMicrosoft Azure TutorialGoogle Cloud PlatformLinuxLinux TutorialLinux Commands A-ZLinux Commands Cheatsheet25 Basic Linux CommandsFile Mangement in LinuxFile Permission Commandschmod Commandchown Commandchgrp Commandunmask CommandLinux System AdministrationLinux File SystemLinux Shell ScriptingLinux NetworkingLinux FirewallLinux Interview QuestionsSoftware TestingSoftware Testing TutorialSoftware Testing TutorialWhat is Software TestingPrinciples of Software TestingTypes of Software TestingLevels of Software TestingAutomation TestingManual TestingTesting ToolsSoftware Testing ToolsDefect Testing ToolsCross-Browser Testing ToolsIntegration Testing ToolUnit Testing ToolsMobile Testing ToolsGUI Testing ToolSecurity Testing ToolsPenetration Testing ToolsSeleniumSelenium TutorialSelenium BasicsSelenium PythonJiraJira TutorialJIRA InstallationJIRA LoginJIRA DashboardSoftware EngineeringSoftware Engineering TutorialSoftware Development Life Cycle (SDLC)Software CharacteristicsSoftware QualityWaterfall ModelIterative Waterfall ModelSpiral ModelPrototyping ModelIncremental Process ModelInterview QuestionsSoftware Testing Interview QuestionsAutomation Testing Interview QuestionsManual Testing Interview QuestionsSoftware Engineering Interview QuestionsPenetration Testing Interview QuestionsAPI Testing Interview QuestionsPostmanPostman TutorialPostman for API DevelopmentDownload and Install PostmanAPI Testing Using PostmanGenerate HTML Report for PostmanDatabasesDBMS TutorialSQL TutorialPostgreSQL TutorialMongoDB TutorialSQL Interview QuestionsMySQL Interview QuestionsPL/SQL Interview QuestionsAndroidAndroid TutorialAndroid Studio TutorialKotlin For AndroidAndroid ProjectsAndroid Interview Questions6 Weeks of Android App DevelopmentExcelMS Excel TutorialIntroduction to MS ExcelData Analysis in ExcelBasic Excel Formulas & FunctionsData Analysis in Advanced ExcelWorkbooksStatistical FunctionsData Visualization in ExcelPivot Tables in ExcelExcel Spreadsheets in PythonBasic Excel ShortcutsMathematicsNumber SystemAlgebraLinear AlgebraTrigonometrySet TheoryStatisticsProbabilityGeometryMensurationLogarithmsCalculusCommerceBusiness StudiesAccountancyMicroeconomicsStatistics for EconomicsMacroeconomicsHuman Resource Management (HRM)ManagementIncome TaxFinanceCommerce Complete GuideSEO-Search Engine OptimizationWhat is SEOSearch Engine Optimization BasicsTypes of SEOKeyword Optimization in SEOBacklinks in SEOSEO BlogsMobile SEOSEO Complete ReferenceAptitudeAptitude Question and AnswersQuantitative AptitudeLogical ReasoningVerbal AbilityDSAData StructuresArraysMatrixStringsLinked ListSingly Linked ListDoubly Linked ListCircular Linked ListDoubly Circular Linked ListLinked List TutorialStackQueueTreeGeneric TreeBinary TreeBinary Search TreeAVL TreeB TreeB+ TreeRed Black TreeTree Data Structure TutorialHeapHashingGraphSet Data StructureMap Data StructureAdvanced Data StructureData Structures TutorialAlgorithmsAnalysis of AlgorithmsDesign and Analysis of AlgorithmsAsymptotic AnalysisAsymptotic NotationsWorst, Average and Best CasesSearching AlgorithmsLinear SearchBinary SearchSearching Algorithms TutorialSorting AlgorithmsSelection SortBubble SortInsertion SortMerge SortQuick SortHeap SortCounting SortRadix SortBucket SortSorting Algorithms TutorialGreedy AlgorithmsDynamic ProgrammingGraph AlgorithmsPattern SearchingRecursionBacktrackingDivide and ConquerMathematical AlgorithmsGeometric AlgorithmsBitwise AlgorithmsRandomized AlgorithmsBranch and BoundAlgorithms TutorialDSA TutorialPracticeAll DSA ProblemsProblem of the DayCompany Wise Coding PracticeAmazonMicrosoftFlipkartExplore AllGfG SDE SheetPractice Problems Difficulty WiseSchoolBasicEasyMediumHardLanguage Wise Coding PracticeCPPJavaPythonCurated DSA ListsBeginner's DSA SheetTop 50 Array ProblemsTop 50 String ProblemsTop 50 DP ProblemsTop 50 Graph ProblemsTop 50 Tree ProblemsCompetitive ProgrammingCompany Wise SDE SheetsFacebook SDE SheetAmazon SDE SheetApple SDE SheetNetflix SDE SheetGoogle SDE SheetDSA Cheat SheetsSDE SheetDSA Sheet for BeginnersFAANG Coding SheetProduct-Based Coding SheetCompany-Wise Preparation SheetTop Interview QuestionsTop 100 DSA Interview Questions Topic-wisePuzzlesAll PuzzlesTop 100 Puzzles Asked In InterviewsTop 20 Puzzles Commonly Asked During SDE InterviewsData SciencePython TutorialR TutorialMachine LearningData Science using PythonData Science using RData Science PackagesPandas TutorialNumPy TutorialData VisualizationPython Data Visualization TutorialData Visualization with RData AnalysisData Analysis with PythonData Analysis with RDeep LearningNLP TutorialWeb TechHTML TutorialCSS TutorialJavaScript TutorialPHP TutorialReactJS TutorialNodeJS TutorialAngularJS TutorialBootstrap TutorialWeb Development Using PythonDjangoGetting started with DjangoCreate an App in DjangoViews In DjangoDjango TemplatesDjango URL patternsDjango Admin InterfaceDjango ModelsMySQL Databased with DjangoDjango CRUDDjango FormsDjango Static FileProjects for BeginnersDjango TutorialFlaskWeb Development Using FlaskFlask App RoutingURL building in FlaskFlask TemplatesTemplating With Jinja2 in FlaskFlask ModelDatabase with Flask SQL AlchemyAuthentication with FlaskWTForms in FlaskStatic files in FlaskPython Flask ProjectsFlask Interview QuestionsFrontend ProjectsBuilding a Survey Form using HTML and CSSFood delivery system using HTML and CSSToDo webapp using DjangoBuilding Blog CMSAdd Pagination in DjangoTailwind CSS with DjangoDjango with ReactjsPostmanGithubJSON TutorialTypeScript TutorialWordpress TutorialWeb DesignWeb BrowsersGoogle ChromeMozilla FirefoxApple SafariMicrosoft EdgeTorCheat SheetsHTML Cheat SheetCSS Cheat SheetJavaScript Cheat SheetReact Cheat SheetAngular Cheat SheetjQuery Cheat SheetBootstrap Cheat SheetJavaScript ProjectsLearn Complete Web DevelopmentFile FormatsCoursesCoding for EveryoneDSA to DevelopmentMachine Learning and Data ScienceDSA CoursesData Structure & Algorithm(C++/JAVA)Data Structure & Algorithm(Python)Data Structure & Algorithm(JavaScript)Programming LanguagesCPPJavaPythonJavaScriptC

Home

Saved Videos

Courses

Data Structures and Algorithms

DSA Tutorial

Data Structures Tutorial

Algorithms Tutorial

Top 100 DSA Interview Questions

DSA-Roadmap[Basic-to-Advanced]

ML & Data Science

Learn Python

Data Science Tutorial

Machine Learning Tutorial

Deep Learning Tutorial

NLP Tutorial

Computer Vision Tutorial

Web Development

HTML Tutorial

CSS Tutorial

JavaScript Tutorial

ReactJS Tutorial

NodeJS Tutorial

Languages

C

C++

Java

R Tutorial

Golang

Interview Corner

Company Interview Corner

Experienced Interviews

Internship Experiences

Practice Company Questions

Competitive Programming

CS Subjects

Operating Systems

DBMS

Computer Networks

Software Engineering

Software Testing

Jobs

Get Hired: Apply for Jobs

Job-a-thon: Hiring Challenge

Corporate Hiring Solutions

Practice

All DSA Problems

Problem of the Day

GFG SDE Sheet

Beginner's DSA Sheet

Love Babbar Sheet

Top 50 Array Problems

Top 50 String Problems

Top 50 DP Problems

Top 50 Graph Problems

Top 50 Tree Problems

Contests

World Cup Hack-A-Thon

GFG Weekly Coding Contest

Job-A-Thon: Hiring Challenge

BiWizard School Contest

All Contests and Events

GBlog

Puzzles

What's New ?

Change Language

HTML TutorialHTML ExercisesHTML TagsHTML AttributesGlobal AttributesEvent AttributesHTML Interview QuestionsHTML DOMDOM Audio/VideoHTML 5HTML ExamplesColor PickerA to Z GuideHTML Formatter

Open In App

Solve Coding ProblemsHTML accept AttributeHTML accept-charset AttributeHTML accesskey AttributeHTML action AttributeHTML align AttributeHTML alt attributeHTML | async AttributeHTML autocomplete AttributeHTML autoplay AttributeHTML autofocus AttributeHTML bgcolor AttributeHTML border attributeHTML | charset AttributeHTML checked AttributeHTML | cite attributeHTML Class AttributeHTML cols AttributeHTML colspan AttributeHTML | content AttributeHTML contenteditable AttributeHTML | controls AttributeHTML | coords AttributeHTML | data AttributeHTML | data AttributeHTML datetime AttributeHTML | default AttributeHTML | defer AttributeHTML dir AttributeHTML | dirname AttributeHTML | disabled AttributeHTML | download AttributeHTML draggable AttributeHTML | dropzone AttributeHTML enctype AttributeHTML | for AttributeHTML | form AttributeHTML formaction AttributeHTML headers attributeHTML height AttributeHTML hidden AttributeHTML | high AttributeHTML href AttributeHTML hreflang AttributeHTML | http-equiv AttributeHTML Id AttributeHTML | ismap AttributeHTML | kind AttributeHTML | label AttributeHTML lang AttributeHTML | list AttributeHTML | loop AttributeHTML | low AttributeHTML max attributeHTML maxlength AttributeHTML media attributeHTML | method AttributeHTML min AttributeHTML | multiple AttributeHTML | muted AttributeHTML | name AttributeHTML | novalidate AttributeHTML | onblur AttributeHTML oncopy AttributeHTML oncut AttributeHTML | onkeypress AttributeHTML | onmousedown AttributeHTML onscroll AttributeHTML Optimum AttributeHTML | pattern AttributeHTML placeholder AttributeHTML readonly AttributeHTML required AttributeHTML reversed AttributeHTML | rows AttributeHTML rowspan AttributeHTML selected AttributeHTML size AttributeHTML | srclang AttributeHTML | start AttributeHTML | step AttributeHTML style attributeHTML tabindex AttributeHTML | target AttributeHTML title AttributeHTML5 translate AttributeHTML | value AttributeHTML | wrap Attribute

Solve Coding ProblemsHTML accept AttributeHTML accept-charset AttributeHTML accesskey AttributeHTML action AttributeHTML align AttributeHTML alt attributeHTML | async AttributeHTML autocomplete AttributeHTML autoplay AttributeHTML autofocus AttributeHTML bgcolor AttributeHTML border attributeHTML | charset AttributeHTML checked AttributeHTML | cite attributeHTML Class AttributeHTML cols AttributeHTML colspan AttributeHTML | content AttributeHTML contenteditable AttributeHTML | controls AttributeHTML | coords AttributeHTML | data AttributeHTML | data AttributeHTML datetime AttributeHTML | default AttributeHTML | defer AttributeHTML dir AttributeHTML | dirname AttributeHTML | disabled AttributeHTML | download AttributeHTML draggable AttributeHTML | dropzone AttributeHTML enctype AttributeHTML | for AttributeHTML | form AttributeHTML formaction AttributeHTML headers attributeHTML height AttributeHTML hidden AttributeHTML | high AttributeHTML href AttributeHTML hreflang AttributeHTML | http-equiv AttributeHTML Id AttributeHTML | ismap AttributeHTML | kind AttributeHTML | label AttributeHTML lang AttributeHTML | list AttributeHTML | loop AttributeHTML | low AttributeHTML max attributeHTML maxlength AttributeHTML media attributeHTML | method AttributeHTML min AttributeHTML | multiple AttributeHTML | muted AttributeHTML | name AttributeHTML | novalidate AttributeHTML | onblur AttributeHTML oncopy AttributeHTML oncut AttributeHTML | onkeypress AttributeHTML | onmousedown AttributeHTML onscroll AttributeHTML Optimum AttributeHTML | pattern AttributeHTML placeholder AttributeHTML readonly AttributeHTML required AttributeHTML reversed AttributeHTML | rows AttributeHTML rowspan AttributeHTML selected AttributeHTML size AttributeHTML | srclang AttributeHTML | start AttributeHTML | step AttributeHTML style attributeHTML tabindex AttributeHTML | target AttributeHTML title AttributeHTML5 translate AttributeHTML | value AttributeHTML | wrap Attribute

HTML bgcolor Attribute

Improve

Improve

Improve

Like Article

Like

Save Article

Save

Share

Report issue

Report

HTML bgcolor attribute is used to set the background color of an HTML element. Bgcolor is one of those attributes that has become deprecated with the implementation of Cascading Style Sheets (see CSS Backgrounds). In modern web development, styling, including background color is typically handled using CSS properties rather than HTML attributes.

Note: The bgcolor attribute is not supported in HTML5.

Syntax<"tag" bgcolor="color_name | hex_value | rgb_value">

Attribute ValuesAttribute Values

Description

color_name

It sets the background color by using the color name. For example “red”.

hex_number

It sets the background color by using the color hex code. For example “#0000ff”.

rgb_number

It sets the background color by using the RGB code. For example: “RGB(0, 153, 0)”.

Supported tags

Tag

Tag

Tag

Tag

Tag

Tag

Tag

Tag

Tag

Example 1: In this example, the table’s background color is set to green using the bgcolor attribute.

html

             HTML table bgcolor Attribute             

GeeksforGeeks

      

HTML table bgcolor Attribute

      
Tag

Tag

                                                                                                                                                                                          
            Author Details         
NAMEAGEBRANCH
BITTU22CSE
RAM21ECE

Output: 

Example 2: In this example, the bgcolor attribute within the tag is used to set the background color of the entire page to orange.

html

                HTML body Bgcolor Attribute               

        

GeeksforGeeks

        

            HTML             body bgcolor Attribute         

          

            It is a Computer             Science portal For Geeks         

      
  

Output: 

Supported Browsers: Google Chrome 1 and aboveMicrosoft Edge 12 and aboveFirefox 1 and aboveOpera 12.1 and aboveSafari 3 and above

Last Updated :

11 Dec, 2023

Like Article

Save Article

Previous

HTML autofocus Attribute

Next

HTML border attribute

Share your thoughts in the comments

Add Your Comment

Please Login to comment...

Similar Reads

HTML |

bgcolor Attribute

HTML | Marquee bgcolor attribute

HTML | thead bgcolor Attribute

HTML |

bgcolor Attribute

HTML |

bgcolor Attribute

HTML |

bgcolor Attribute

HTML |

bgcolor Attribute

HTML

bgcolor Attribute

HTML bgcolor Attribute

HTML

bgcolor Attribute

Complete Tutorials

React Bootstrap Tutorial

JavaScript Programming Examples

CSS Examples

HTML Examples

Express.js Tutorial

Like

V

Vijay Sirra

Follow

Article Tags :

HTML-Attributes

HTML

Web Technologies

Additional Information

Current difficulty :

Medium

Vote for difficulty :

Easy

Normal

Medium

Hard

Expert

Improved By :

ManasChhabra2chhabradhanviamitsingh2730amanv09pankaj_gupta_gfg

Trending in News

View More

Google Maps testing a new feature that shows entrance to buildingsChatGPT Gets a Voice: Introducing the New Read Aloud FeatureMeta Quest+ is Now Like Game Pass For Your VR HeadsetMLB World Series Champions - Major League Baseball Winners List 30 OOPs Interview Questions and Answers (2024)

Explore More

A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305

CompanyAbout UsLegalCareersIn MediaContact UsAdvertise with usGFG Corporate SolutionPlacement Training ProgramExploreHack-A-ThonsGfG Weekly ContestDSA in JAVA/C++Master System DesignMaster CPGeeksforGeeks VideosGeeks CommunityLanguagesPythonJavaC++PHPGoLangSQLR LanguageAndroid TutorialTutorials ArchiveDSAData StructuresAlgorithmsDSA for BeginnersBasic DSA ProblemsDSA RoadmapTop 100 DSA Interview ProblemsDSA Roadmap by Sandeep JainAll Cheat SheetsData Science & MLData Science With PythonData Science For BeginnerMachine Learning TutorialML MathsData Visualisation TutorialPandas TutorialNumPy TutorialNLP TutorialDeep Learning TutorialHTML & CSSHTMLCSSWeb TemplatesCSS FrameworksBootstrapTailwind CSSSASSLESSWeb DesignDjango TutorialPythonPython Programming ExamplesPython ProjectsPython TkinterWeb ScrapingOpenCV Python TutorialPython Interview QuestionComputer ScienceOperating SystemsComputer NetworkDatabase Management SystemSoftware EngineeringDigital Logic DesignEngineering MathsDevOpsGitAWSDockerKubernetesAzureGCPDevOps RoadmapCompetitive ProgrammingTop DS or Algo for CPTop 50 TreeTop 50 GraphTop 50 ArrayTop 50 StringTop 50 DPTop 15 Websites for CPSystem DesignHigh Level DesignLow Level DesignUML DiagramsInterview GuideDesign PatternsOOADSystem Design BootcampInterview QuestionsJavaScriptJavaScript ExamplesTypeScriptReactJSNextJSAngularJSNodeJSLodashWeb BrowserPreparation CornerCompany-Wise Recruitment ProcessResume TemplatesAptitude PreparationPuzzlesCompany-Wise PreparationSchool SubjectsMathematicsPhysicsChemistryBiologySocial ScienceEnglish GrammarWorld GKManagement & FinanceManagementHR ManagementFinanceIncome TaxOrganisational BehaviourMarketingFree Online ToolsTyping TestImage EditorCode FormattersCode ConvertersCurrency ConverterRandom Number GeneratorRandom Password GeneratorMore TutorialsSoftware DevelopmentSoftware TestingProduct ManagementSAPSEO - Search Engine OptimizationLinuxExcelGeeksforGeeks VideosDSAPythonJavaC++Data ScienceCS Subjects

@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved

We use cookies to ensure you have the best browsing experience on our website. By using our site, you

acknowledge that you have read and understood our

Cookie Policy &

Privacy Policy

Got It !

Improvement

Please go through our recently updated Improvement Guidelines before submitting any improvements.

This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab.

You will be notified via email once the article is available for improvement.

Thank you for your valuable feedback!

Suggest changes

Please go through our recently updated Improvement Guidelines before submitting any improvements.

Suggest Changes

Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.

Create Improvement

Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.

Suggest Changes

Suggestion[CharLimit:2000]

Create Improvement

What kind of Experience do you want to share?

Interview Experiences

Admission Experiences

Engineering Exam Experiences

Work Experiences

Campus Experiences

Add Other Experiences

background-color - CSS: Cascading Style Sheets | MDN

ground-color - CSS: Cascading Style Sheets | MDNSkip to main contentSkip to searchSkip to select languageMDN Web DocsOpen main menuReferencesReferencesOverview / Web TechnologyWeb technology reference for developersHTMLStructure of content on the webCSSCode used to describe document styleJavaScriptGeneral-purpose scripting languageHTTPProtocol for transmitting web resourcesWeb APIsInterfaces for building web applicationsWeb ExtensionsDeveloping extensions for web browsersWeb TechnologyWeb technology reference for developersGuidesGuidesOverview / MDN Learning AreaLearn web developmentMDN Learning AreaLearn web developmentHTMLLearn to structure web content with HTMLCSSLearn to style content using CSSJavaScriptLearn to run scripts in the browserAccessibilityLearn to make the web accessible to allPlusPlusOverviewA customized MDN experienceAI Help (beta)Get real-time assistance and supportUpdatesAll browser compatibility updates at a glanceDocumentationLearn how to use MDN PlusFAQFrequently asked questions about MDN PlusCurriculumNewBlogPlayAI Help BetaSearch MDNClear search inputSearchThemeLog inSign up for freeReferencesCSSbackground-colorArticle ActionsEnglish (US)Filter sidebarClear filter inputIn this articleTry itSyntaxAccessibility concernsFormal definitionFormal syntaxExamplesSpecificationsBrowser compatibilitySee also

CSS

Tutorials

CSS basics

CSS first steps

CSS first steps overview

What is CSS?

Getting started with CSS

How CSS is structured

How CSS works

Assessment: Styling a biography page

CSS building blocks

CSS building blocks overview

CSS selectors

Type, class, and ID selectors

Attribute selectors

Pseudo-classes and pseudo-elements

Combinators

Cascade, specificity, and inheritance

Cascade layers

The box model

Backgrounds and borders

Handling different text directions

Overflowing content

CSS values and units

Sizing items in CSS

Images, media, and form elements

Styling tables

Debugging CSS

Organizing your CSS

Assessment: Fundamental CSS comprehension

Assessment: Creating fancy letterheaded paper

Assessment: A cool-looking box

Styling text

Styling text overview

Fundamental text and font styling

Styling lists

Styling links

Web fonts

Assessment: Typesetting a community school homepage

CSS layout

CSS layout overview

Introduction to CSS layout

Normal Flow

Flexbox

Grids

Floats

Positioning

Multiple-column layout

Responsive design

Beginner's guide to media queries

Legacy layout methods

Supporting older browsers

Assessment: Fundamental layout comprehension

Reference

ModulesCSS animationsCSS backgrounds and bordersCSS basic user interfaceCSS box alignmentCSS box modelCSS cascade and inheritanceCSS custom properties for cascading variablesCSS color adjustmentCSS colorsCSS compositing and blendingCSS conditional rulesCSS containmentCSS counter stylesCSS displayCSS filter effectsCSS flexible box layoutCSS font loadingCSS fontsCSS fragmentationCSS generated contentCSS grid layoutCSS imagesCSS lists and countersCSS logical properties and valuesCSS maskingCSS media queriesCSS miscellaneousCSS motion pathCSS multi-column layoutCSS namespacesCSS nestingCSS overflowCSS overscroll behaviorCSS paged mediaCSS positioned layoutCSS properties and values APICSS pseudo-elementsCSS ruby layoutCSS scopingCSS scroll-driven animationsCSS scroll snapCSS scrollbars stylingCSS selectorsCSS shadow partsCSS shapesCSS syntaxCSS tableCSS textCSS text decorationCSS transformsCSS transitionsCSS writing modesCSSOM view

Properties-moz-*-moz-float-edge

Non-standard

Deprecated

-moz-force-broken-image-icon

Non-standard

Deprecated

-moz-image-region

Non-standard

-moz-orient

Non-standard

-moz-user-focus

Non-standard

Deprecated

-moz-user-input

Non-standard

Deprecated

-webkit-*-webkit-border-before

Non-standard

-webkit-box-reflect

Non-standard

-webkit-line-clamp-webkit-mask-attachment

Non-standard

-webkit-mask-box-image

Non-standard

-webkit-mask-composite

Non-standard

-webkit-mask-position-x

Non-standard

-webkit-mask-position-y

Non-standard

-webkit-mask-repeat-x

Non-standard

-webkit-mask-repeat-y

Non-standard

-webkit-overflow-scrolling

Non-standard

-webkit-tap-highlight-color

Non-standard

-webkit-text-fill-color-webkit-text-security

Non-standard

-webkit-text-stroke-webkit-text-stroke-color-webkit-text-stroke-width-webkit-touch-callout

Non-standard

accent-coloralign-*align-contentalign-itemsalign-selfalign-tracks

Experimental

allanimation-*animationanimation-compositionanimation-delayanimation-directionanimation-durationanimation-fill-modeanimation-iteration-countanimation-nameanimation-play-stateanimation-range

Experimental

animation-range-end

Experimental

animation-range-start

Experimental

animation-timeline

Experimental

animation-timing-functionappearanceaspect-ratiobackdrop-filterbackface-visibilitybackground-*backgroundbackground-attachmentbackground-blend-modebackground-clipbackground-colorbackground-imagebackground-originbackground-positionbackground-position-xbackground-position-ybackground-repeatbackground-sizeblock-sizeborder-*borderborder-blockborder-block-colorborder-block-endborder-block-end-colorborder-block-end-styleborder-block-end-widthborder-block-startborder-block-start-colorborder-block-start-styleborder-block-start-widthborder-block-styleborder-block-widthborder-bottomborder-bottom-colorborder-bottom-left-radiusborder-bottom-right-radiusborder-bottom-styleborder-bottom-widthborder-collapseborder-colorborder-end-end-radiusborder-end-start-radiusborder-imageborder-image-outsetborder-image-repeatborder-image-sliceborder-image-sourceborder-image-widthborder-inlineborder-inline-colorborder-inline-endborder-inline-end-colorborder-inline-end-styleborder-inline-end-widthborder-inline-startborder-inline-start-colorborder-inline-start-styleborder-inline-start-widthborder-inline-styleborder-inline-widthborder-leftborder-left-colorborder-left-styleborder-left-widthborder-radiusborder-rightborder-right-colorborder-right-styleborder-right-widthborder-spacingborder-start-end-radiusborder-start-start-radiusborder-styleborder-topborder-top-colorborder-top-left-radiusborder-top-right-radiusborder-top-styleborder-top-widthborder-widthbottombox-*box-align

Non-standard

Deprecated

box-decoration-breakbox-direction

Non-standard

Deprecated

box-flex

Non-standard

Deprecated

box-flex-group

Non-standard

Deprecated

box-lines

Non-standard

Deprecated

box-ordinal-group

Non-standard

Deprecated

box-orient

Non-standard

Deprecated

box-pack

Non-standard

Deprecated

box-shadowbox-sizingbreak-*break-afterbreak-beforebreak-insidecaption-sidecaret-colorclearclip

Deprecated

clip-pathcolor-*colorcolor-interpolationcolor-schemecolumn-*column-countcolumn-fillcolumn-gapcolumn-rulecolumn-rule-colorcolumn-rule-stylecolumn-rule-widthcolumn-spancolumn-widthcolumnscontain-*containcontain-intrinsic-block-sizecontain-intrinsic-heightcontain-intrinsic-inline-sizecontain-intrinsic-sizecontain-intrinsic-widthcontainer-*containercontainer-namecontainer-typecontentcontent-visibility

Experimental

counter-*counter-incrementcounter-resetcounter-setcursordirectiondisplayempty-cellsfilterflex-*flexflex-basisflex-directionflex-flowflex-growflex-shrinkflex-wrapfloatfont-*fontfont-familyfont-feature-settingsfont-kerningfont-language-overridefont-optical-sizingfont-palettefont-sizefont-size-adjustfont-smooth

Non-standard

font-stretchfont-stylefont-synthesisfont-synthesis-positionfont-synthesis-small-capsfont-synthesis-stylefont-synthesis-weightfont-variantfont-variant-alternatesfont-variant-capsfont-variant-east-asianfont-variant-emojifont-variant-ligaturesfont-variant-numericfont-variant-positionfont-variation-settingsfont-weightforced-color-adjustgapgrid-*gridgrid-areagrid-auto-columnsgrid-auto-flowgrid-auto-rowsgrid-columngrid-column-endgrid-column-startgrid-rowgrid-row-endgrid-row-startgrid-templategrid-template-areasgrid-template-columnsgrid-template-rowshanging-punctuationheighthyphenate-characterhyphenate-limit-charshyphensimage-*image-orientationimage-renderingimage-resolution

Experimental

initial-letter

Experimental

initial-letter-align

Experimental

inline-sizeinset-*insetinset-blockinset-block-endinset-block-startinset-inlineinset-inline-endinset-inline-startisolationjustify-*justify-contentjustify-itemsjustify-selfjustify-tracks

Experimental

leftletter-spacingline-*line-breakline-heightline-height-step

Experimental

list-*list-stylelist-style-imagelist-style-positionlist-style-typemargin-*marginmargin-blockmargin-block-endmargin-block-startmargin-bottommargin-inlinemargin-inline-endmargin-inline-startmargin-leftmargin-rightmargin-topmargin-trim

Experimental

mask-*maskmask-bordermask-border-modemask-border-outsetmask-border-repeatmask-border-slicemask-border-sourcemask-border-widthmask-clipmask-compositemask-imagemask-modemask-originmask-positionmask-repeatmask-sizemask-typemasonry-auto-flow

Experimental

math-*math-depthmath-shift

Experimental

math-stylemax-*max-block-sizemax-heightmax-inline-sizemax-widthmin-*min-block-sizemin-heightmin-inline-sizemin-widthmix-blend-modeobject-fitobject-positionoffset-*offsetoffset-anchoroffset-distanceoffset-pathoffset-positionoffset-rotateopacityorderorphansoutline-*outlineoutline-coloroutline-offsetoutline-styleoutline-widthoverflow-*overflowoverflow-anchoroverflow-blockoverflow-clip-marginoverflow-inlineoverflow-wrapoverflow-xoverflow-yoverlay

Experimental

overscroll-*overscroll-behavioroverscroll-behavior-blockoverscroll-behavior-inlineoverscroll-behavior-xoverscroll-behavior-ypadding-*paddingpadding-blockpadding-block-endpadding-block-startpadding-bottompadding-inlinepadding-inline-endpadding-inline-startpadding-leftpadding-rightpadding-toppage-*pagepage-break-afterpage-break-beforepage-break-insidepaint-orderperspectiveperspective-originplace-*place-contentplace-itemsplace-selfpointer-eventspositionprint-color-adjustquotesresizerightrotaterow-gapruby-align

Experimental

ruby-positionscalescroll-*scroll-behaviorscroll-marginscroll-margin-blockscroll-margin-block-endscroll-margin-block-startscroll-margin-bottomscroll-margin-inlinescroll-margin-inline-endscroll-margin-inline-startscroll-margin-leftscroll-margin-rightscroll-margin-topscroll-paddingscroll-padding-blockscroll-padding-block-endscroll-padding-block-startscroll-padding-bottomscroll-padding-inlinescroll-padding-inline-endscroll-padding-inline-startscroll-padding-leftscroll-padding-rightscroll-padding-topscroll-snap-alignscroll-snap-stopscroll-snap-typescroll-timeline

Experimental

scroll-timeline-axis

Experimental

scroll-timeline-name

Experimental

scrollbar-*scrollbar-colorscrollbar-gutterscrollbar-widthshape-*shape-image-thresholdshape-marginshape-outsidetab-sizetable-layouttext-*text-aligntext-align-lasttext-combine-uprighttext-decorationtext-decoration-colortext-decoration-linetext-decoration-skip

Experimental

text-decoration-skip-inktext-decoration-styletext-decoration-thicknesstext-emphasistext-emphasis-colortext-emphasis-positiontext-emphasis-styletext-indenttext-justifytext-orientationtext-overflowtext-renderingtext-shadowtext-size-adjust

Experimental

text-transformtext-underline-offsettext-underline-positiontext-wraptimeline-scope

Experimental

toptouch-actiontransform-*transformtransform-boxtransform-origintransform-styletransition-*transitiontransition-behaviortransition-delaytransition-durationtransition-propertytransition-timing-functiontranslateunicode-bidiuser-modify

Non-standard

Deprecated

user-selectvertical-alignview-*view-timeline

Experimental

view-timeline-axis

Experimental

view-timeline-inset

Experimental

view-timeline-name

Experimental

view-transition-name

Experimental

visibilitywhite-spacewhite-space-collapsewidowswidthwill-changeword-breakword-spacingwriting-modez-indexzoom

Non-standard

SelectorsAttribute selectorsClass selectorsID selectors& nesting selectorType selectorsUniversal selectors

CombinatorsChild combinatorColumn combinator

Experimental

Descendant combinatorNamespace separatorNext-sibling combinatorSelector listSubsequent-sibling combinator

Pseudo-classes:-moz-broken

Non-standard

:-moz-drag-over

Non-standard

:-moz-first-node

Non-standard

:-moz-handler-blocked

Non-standard

:-moz-handler-crashed

Non-standard

:-moz-handler-disabled

Non-standard

:-moz-last-node

Non-standard

:-moz-loading

Non-standard

:-moz-locale-dir(ltr)

Non-standard

:-moz-locale-dir(rtl)

Non-standard

:-moz-only-whitespace

Non-standard

:-moz-submit-invalid

Non-standard

:-moz-suppressed

Non-standard

:-moz-user-disabled

Non-standard

:-moz-window-inactive

Non-standard

:active:any-link:autofill:blank

Experimental

:buffering:checked:current:default:defined:dir():disabled:empty:enabled:first:first-child:first-of-type:focus:focus-visible:focus-within:fullscreen:future:has():host:host-context():host():hover:in-range:indeterminate:invalid:is():lang():last-child:last-of-type:left:link:local-link:modal:muted:not():nth-child():nth-last-child():nth-last-of-type():nth-of-type():only-child:only-of-type:optional:out-of-range:past:paused:picture-in-picture:placeholder-shown:playing:popover-open:read-only:read-write:required:right:root:scope:seeking:stalled:state()

Experimental

:target:target-within

Experimental

:user-invalid:user-valid:valid:visited:volume-locked:where()

Pseudo-elements::-moz-color-swatch

Non-standard

::-moz-focus-inner

Experimental

::-moz-list-bullet

Non-standard

::-moz-list-number

Non-standard

::-moz-page

Non-standard

::-moz-page-sequence

Non-standard

::-moz-progress-bar

Non-standard

::-moz-range-progress

Non-standard

::-moz-range-thumb

Non-standard

::-moz-range-track

Non-standard

::-moz-scrolled-page-sequence

Non-standard

::-webkit-inner-spin-button

Non-standard

::-webkit-meter-bar

Non-standard

::-webkit-meter-even-less-good-value

Non-standard

::-webkit-meter-inner-element

Non-standard

::-webkit-meter-optimum-value

Non-standard

::-webkit-meter-suboptimum-value

Non-standard

::-webkit-progress-bar

Non-standard

::-webkit-progress-inner-element

Non-standard

::-webkit-progress-value

Non-standard

::-webkit-scrollbar

Non-standard

::-webkit-search-cancel-button

Non-standard

::-webkit-search-results-button

Non-standard

::-webkit-slider-runnable-track

Experimental

::-webkit-slider-thumb

Experimental

::after::backdrop::before::cue::cue-region::file-selector-button::first-letter::first-line::grammar-error::highlight()::marker::part()::placeholder::selection::slotted()::spelling-error::target-text

Experimental

::view-transition

Experimental

::view-transition-group

Experimental

::view-transition-image-pair

Experimental

::view-transition-new

Experimental

::view-transition-old

Experimental

At-rules@charset@color-profile@container@counter-style@document

Non-standard

Deprecated

@font-face@font-feature-values@font-palette-values@import@keyframes@layer@media@namespace@page@property@scope@starting-style

Experimental

@supports

Functions-moz-image-rect

Non-standard

Deprecated

abs()acos()asin()atan()atan2()attr()calc()clamp()cos()counter()counters()cross-fade()element()

Experimental

env()exp()fit-content()hypot()log()max()min()minmax()mod()path()pow()ray()rem()repeat()round()sign()sin()sqrt()symbols()tan()url()var()

Types

Deprecated

Guides

Animations

Using CSS animations

Backgrounds and Borders

Using multiple backgrounds

Resizing background images

Box alignment

Box alignment in block layout

Box alignment in flexbox

Box alignment in grid layout

Box alignment in multi-column layout

Box model

Introduction to the CSS basic box model

Mastering margin collapsing

Colors

Applying color to HTML elements using CSS

Web Accessibility: Understanding colors and luminance

Web Accessibility: Color contrast

Columns

Basic concepts of Multicol

Styling columns

Spanning and balancing

Handling overflow in Multicol

Content breaks in Multicol

Conditional rules

Using feature queries

Containment

Using CSS containment

CSS container queries

Using container size and style queries

CSSOM view

Coordinate systems

Flexbox

Basic concepts of Flexbox

Comparison with other layout methods

Aligning items in a flex container

Ordering flex items

Controlling flex item ratios

Mastering wrapping of flex items

Typical use cases of Flexbox

Flow layout

Block and Inline layout in normal flow

In flow and Out of flow

Formatting contexts explained

Flow layout and writing modes

Flow layout and overflow

Fonts

OpenType font features guide

Variable fonts guide

Grid

Basics concepts of grid layout

Relationship to other layout methods

Line-based placement

Grid template areas

Layout using named grid lines

Auto-placement in grid layout

Box alignment in grid layout

Grids, logical values and writing modes

Grid layout and accessibility

Grid Layout and progressive enhancement

Realizing common layouts using grids

Subgrid

Masonry layout

Images

Using CSS gradients

Lists and counters

Using CSS counters

Consistent list indentation

Logical properties

Basic concepts

Floating and positioning

Margins, borders and padding

Sizing

Math functions

Using CSS math functions

Media queries

Using media queries

Using media queries for accessibility

Testing media queries programmatically

Printing

Nesting style rules

Using CSS nesting

Nesting at-rules

Nesting and specificity

Positioning

Understanding CSS z-index

Scroll snap

Basic concepts of scroll snap

Shapes

Overview of shapes

Shapes from box values

Basic shapes

Shapes from images

Text

Wrapping and breaking text

Transforms

Using transforms

Transitions

Using transitions

Layout cookbook

Media objects

Columns

Center an element

Sticky footers

Split navigation

Breadcrumb navigation

List group with badges

Pagination

Card

Grid wrapper

Tools

Color picker

Box shadow generator

Border image generator

Border radius generator

In this articleTry itSyntaxAccessibility concernsFormal definitionFormal syntaxExamplesSpecificationsBrowser compatibilitySee alsobackground-colorThe background-color CSS property sets the background color of an element.Try itSyntaxcss/* Keyword values */

background-color: red;

background-color: indigo;

/* Hexadecimal value */

background-color: #bbff00; /* Fully opaque */

background-color: #bf0; /* Fully opaque shorthand */

background-color: #11ffee00; /* Fully transparent */

background-color: #1fe0; /* Fully transparent shorthand */

background-color: #11ffeeff; /* Fully opaque */

background-color: #1fef; /* Fully opaque shorthand */

/* RGB value */

background-color: rgb(255 255 128); /* Fully opaque */

background-color: rgb(117 190 218 / 50%); /* 50% transparent */

/* HSL value */

background-color: hsl(50 33% 25%); /* Fully opaque */

background-color: hsl(50 33% 25% / 75%); /* 75% opaque, i.e. 25% transparent */

/* Special keyword values */

background-color: currentcolor;

background-color: transparent;

/* Global values */

background-color: inherit;

background-color: initial;

background-color: revert;

background-color: revert-layer;

background-color: unset;

The background-color property is specified as a single value.Values

The uniform color of the background. It is rendered behind any background-image that is specified, although the color will still be visible through any transparency in the image.

Accessibility concernsIt is important to ensure that the contrast ratio between the background color and the color of the text placed over it is high enough that people experiencing low vision conditions will be able to read the content of the page.

Color contrast ratio is determined by comparing the luminance of the text and background color values. In order to meet current Web Content Accessibility Guidelines (WCAG), a ratio of 4.5:1 is required for text content and 3:1 for larger text such as headings. Large text is defined as 18.66px and bold or larger, or 24px or larger.

WebAIM: Color Contrast Checker

MDN Understanding WCAG, Guideline 1.4 explanations

Understanding Success Criterion 1.4.3 | W3C Understanding WCAG 2.0

Formal definitionInitial valuetransparentApplies toall elements. It also applies to ::first-letter and ::first-line.InheritednoComputed valuecomputed colorAnimation typea colorFormal syntaxbackground-color = ExamplesHTMLhtml

Lorem ipsum dolor sit amet, consectetuer

Lorem ipsum dolor sit amet, consectetuer

Lorem ipsum dolor sit amet, consectetuer

CSScss.exampleone {

background-color: transparent;

}

.exampletwo {

background-color: rgb(153 102 153);

color: rgb(255 255 204);

}

.examplethree {

background-color: #777799;

color: #ffffff;

}

ResultSpecificationsSpecificationCSS Backgrounds and Borders Module Level 3 # background-colorBrowser compatibilityBCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.See also

Multiple backgrounds

The data type

Other color-related properties: color, border-color, outline-color, text-decoration-color, text-emphasis-color, text-shadow, caret-color, and column-rule-color

Applying color to HTML elements using CSS

Help improve MDNWas this page helpful to you?YesNoLearn how to contribute.This page was last modified on Jan 2, 2024 by MDN contributors.View this page on GitHub • Report a problem with this contentMDN logoYour blueprint for a better internet.MDN on MastodonMDN on X (formerly Twitter)MDN on GitHubMDN Blog RSS FeedMDNAboutBlogCareersAdvertise with usSupportProduct helpReport an issueOur communitiesMDN CommunityMDN ForumMDN ChatDevelopersWeb TechnologiesLearn Web DevelopmentMDN PlusHacks BlogMozilla logoWebsite Privacy NoticeCookiesLegalCommunity Participation GuidelinesVisit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.Portions of this content are ©1998–2024 by individual mozilla.org contributors. Content available under a Creative Commons licen

HTML Tutorial - Bgcolor

HTML Tutorial - Bgcolor

Home Web TutorialsBeginner Tutorial

HTML Tutorial

CSS Tutorial

Scripting

Javascript Tutorial

PHP Tutorial

Perl Tutorial

Ajax Tutorial

ASP Tutorial

VBScript Tutorial

Databases

SQL Tutorial

MySQL Tutorial

Miscellaneous

XML Tutorial

Webhost Tutorial

Flash Tutorial

SEO Tutorial

HTML Tutorial

HTML - Introduction

HTML - Elements

HTML - Tags

HTML - Text

HTML - Formatting

HTML - Pre

HTML - Attributes

HTML - Font

HTML - Text Links

HTML - Comments

HTML - Lists

HTML - Images

HTML - Image Links

HTML - Tables

HTML - Bgcolor

HTML - Color Codes

HTML - Color Chart

HTML - Background

Web Forms

HTML - Forms

HTML - Input

HTML - Text Fields

HTML - Password

HTML - Reset

HTML - Submit

HTML - Checkboxes

HTML - Radio

HTML - Select

HTML - Hidden Fields

HTML - Upload

HTML - Textareas

Special Tags

HTML - Body

HTML - Music Codes

HTML - Video Codes

HTML - Meta

HTML - Style

HTML - Div

HTML - Layouts

HTML - Frames

HTML - Entities

HTML - Scripts

Formatting Tags

HTML - Bold

HTML - Paragraphs

HTML - Headings

HTML - Line Breaks

HTML - Horizontal Rule

HTML - Email

HTML - Italic

HTML - Code

HTML - Superscript

HTML - Subscript

HTML - Strikethrough

Get Help!HTML Forum Contact Us

HTML - The bgcolor Attribute

The bgcolor attribute is used to set the background color of an HTML element. Bgcolor is one of those attributes that has become deprecated with the implementation of Cascading Style Sheets (see CSS Backgrounds). The reason we've included it in this tutorial is because it will give us an opportunity to introduce web colors and also add some life to our HTML web page as we continue to progress through this tutorial. It will serve as a visual aid for you as you are learning the mechanics of building a table.

Advertise on Tizag.com

Without much effort, we can bring that boring white web page to life by adding some color with the bgcolor attribute.

HTML Bgcolor Code:

This page now has a SILVER background!

HTML Bgcolor:

This page now has a SILVER background!

HTML - Web Colors

Our example uses the text value, which is one of three different types of color values that can be used with the bgcolor attribute. Below is a table of the 16 basic HTML color values that are available to HTML web designers.

HTML Basic Colors:

Black Gray Silver White

Yellow Lime Aqua Fuchsia

Red Green Blue Purple

Maroon Olive Navy Teal

While the table above illustrates only 16 colors, 16 is surely not the limit to our color wheel. As we mentioned, HTML supports three different types of color values including text values (which we've pretty much covered above), numeric, (RGB) and hexadecimal values. We'll go into more detail regarding these values so just sit tight. This next example offers a sneak peak at what these values may look like.

HTML Code:

A red colored table background using hexadecimal values "#FF0000".

A blue colored table background using numeric, RGB values "rgb(0, 0, 255)".

A lime colored table background using color names.

Table Bgcolor Values:

A lime colored table background using color names.

A red colored table background using hexadecimal values "#FF0000".

A blue colored table background using numeric, RGB values "rgb(0, 0, 255)".

Hexadecimal and numeric color values (RGB) allow HTML developers to expand the color wheel beyond 16 colors. Way beyond 16, in fact. Nonetheless, there's no need to memorize 256+ unique color combinations; instead, we can use numeric and hexadecimal values and calculate color shades. We'll show you how to use them in our HTML Color Codes page.

HTML - Coloring Fonts, Table Rows, & Table Columns

Here's a few common examples of bgcolor in action.

HTML Bgcolor Code:

This Row is Yellow!
This Row is Gray!
This Row is Yellow!
This Row is Gray!
This Row is Yellow!
This Row is Gray!

Alternating Table Row Colors:

This Row is Yellow!

This Row is Gray!

This Row is Yellow!

This Row is Gray!

This Row is Yellow!

This Row is Gray!

Check out this "Scoreboard" we made with the use of font color and

bgcolor!

HTML Code:

Green Bay

13

New England

27

Scoreboard:

Green Bay

13

New England

27

Go BackContinueTips

If you are new to HTML, consider sticking with color names for setting your background color.

There are 256 "true colors" with hexadecimal values. The colors are made out of hex-pairs for red, green, and blue. Examples: #99FFCC, #33AA44.

Shades of gray occur when the 3 paired amounts of each color are equal. Example. "rgb(100,100,100)", "#333333," "#0A0A0A"

Avoid bright, headache-causing color schemes! Keep your coloring distinct and purposeful.

For more information about colors, check out our HTML Color Codes lesson.

Found Something Wrong in this Lesson?Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!

Web Reference

HTML Reference

CSS Reference

CSS Examples

PHP Examples

Help Tizag Grow Link to Tizag

Tizag.com Store

Advertise Here

More Tutorials!

Microsoft Office Tutorials

Artist Tutorials

2003-2008 Erack Network | Copyright | Privacy Policy | Advertising Information

Site design by Seattle Web Design

CSS Background Color – How to Change the Background Color in HTML

CSS Background Color – How to Change the Background Color in HTML

Search

Submit your search query

Forum

Donate

August 4, 2021

/

#CSS

CSS Background Color – How to Change the Background Color in HTML

Ilenia Magoni

You have started creating your HTML page, and you want to give it some color – maybe change the color of the text or set a nice background. So how do you do that?In this article I'll show you how you can change the background color of a page in a few different ways.How to Change the Background Color of an HTML ElementYou can change the background color of an HTML element using the background-color CSS property and giving it a value of a color.p {

background-color: pink;

}With this code, the paragraphs are given a pink background.For example, this code will make all paragraph elements in your HTML file have a pink background because the background-color property has a value of pink.There are about 140 color names that you can use, like teal, hotpink, indigo and many others.A few of the possible color names you can useNote: if you give a background-color to an element and don't see it change, it can be a syntax error, or it can also be that the element does not have a width or height. Try to put some content in it, or give it a width and an height using the CSS properties width and height.There are actually almost 16.8 million colors that you can use. You can use all these colors using RGB values. There are also HSL colors where you have about 3.7 million colors to choose from. In the next section you will learn about all these different ways of creating colors.Different Color NotationsThe background-color property accepts colors as possible values. Here you will see four different notations for color values.The first will be color names, and there are around 140 keywords that you can use. This is the easiest way to choose a color as it doesn't require understanding special notations – but it has a limited range of options.The second and third ways to name or choose colors are RGB values and hexadecimal values. In these notations, colors are identified by the amount of red, green, and blue that they contain. This comes from how a screen produces color. A screen is made of pixels, and each pixel is lighted by LEDs of three different colors, green, blue and red, that can shine at different intensities.The fourth notation is HSL colors, or Hue-Saturation-Lightness. This notation comes from Graphic Design, as it reflects a more natural way for humans to think about color: a pure color (hue), of which saturation and lightness can be varied.You can use any of these color notations to give a color to the background, but let's see them in more details, so you can choose the one you prefer.HTML Color NamesThere are 16 basic colors recognised in the first version of HTML. Now there are 140+ named colors you can use.The 16 basic colorsbody {

background-color: black;

}WIth this CSS, the body is given a black backgroundAn example of an HTML page with the body being given a background-color of blackYou can see all the named colors in the appendix at the end of the article.RGB ColorsRGB stands for Red-Green-Blue. The colors in this format are written rgb(0,0,0), where each value is a number between 0 and 255 representing the amount of red, green, and blue used to make each color, respectively. For example, if you have rgb(0,0,0) you get black.To get red, you write rgb(255,0,0), where there is as much red as possible with 255, 0 for blue, and 0 for green. You can get other variations of red with small amounts of green and/or blue, and a bit less red. For example you can get an orange red with rgb(255,69,0) or a dark red with rgb(139,0,0).The colors of the rgb values presented above.div {

background-color: rgb(139,0,0);

}The div elements are given a dark red background.An example of an HTML page with the div element being given a background-color of rgb(139,0,0)Below an example of how the color changes when you adjust two of the RGB values: the top left corner of the colored square is equal to rgb(0,0,0), the top right is equal to rgb(0,0,255), the bottom left corner to rgb(0,255,0) and the bottom right corner to rgb(0,255,255).Fortunately, you don't need to guess the numbers to get the color you want. You can find various color pickers online that let you choose the color with sliders (or other methods) and give you the RGB color value you want to use.Hexadecimal ColorsHexadecimal colors are a different way to write RGB colors. With hexadecimals you also have three numbers, one for each color, with 256 possible values.In this case, though, each color has two digits that go from 0 to F (that is,  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and A, B, C, D, E, F). One single digit has 16 possible values, and two digits have 256 possible values, from 00, to FF (255).Hexadecimal colors are written with a # in front of the value. Red is written as #FF0000, dark red as #8B0000, and orange red as #FF4500, for example.The colors mentioned in the section above.h1 {

background-color: #FF4500;

}The h1 elements are given a background of orange red.An example of an HTML page with the h1 element being given a background-color of #FF4500You can also use color pickers to generate hexadecimal values.Hexadecimal shorthandYou can write hexadecimal numbers in shorthand form, using only three digits instead of six. For example, you can write red like #F00. This reduces the number of possible colors to just above 4,000, but it is shorter to write, and sometimes that is what is important.Each digit is in place of two identical digits, so we can't write #8B0000 in shorthand form, as 8 and B are not identical. But we can write #800 which is equal to #880000, pretty similar to the other dark red. And orange red can be #F40 (equal to #FF4400).The colors mentioned in the section above.HSL ColorsHSL means Hue-Saturation-Lightness, and it is a completely different way of writing colors than what we have seen so far.HSL colors are represented with three numbers: the hue goes from 0 to 360, and saturation and lightness from 0 to 100.The hue determines the base color, and its value is an angle, a degree on the color wheel. In this case, red is 0, green is 120, blue is 240, and 360 is again red.All possible colors changing only the hue, with hue of 0 to the left and hue of 360 on the right.Saturation goes from 0, which makes the color gray, to 100, which shows the full color.Variation of saturation for red, 0% on the left, 100% on the right.Lightness is the amount of black or white added to the color. 0 is black, 50 is the color itself, and 100 is white.Variation of lightness, with 0% on the left, and 100% on the right.For example, you'd write red as hsl(0,100%,50%), orange red as hsl(16,100%,50%), and dark red as hsl(0,100%,27%).It can be easier to find similar colors using HSL than with the other color schemes. With red and its variations you have seen that to get a darker red you can just change the lightness percentage, and mixing red with an other color is enough to change its hue value a bit.Let's see it in action with a mixed color in hexadecimal, like orange (#FFA500 or rgb(255,166,0)), written in HSL as hsl(39,100%,50%). You can get a lighter orange just by increasing the lightness. So for example you can write hsl(39,100%,65%) to get this lighter orange. With the other notations you would have needed to write rgb(255,193,77) or #FFC14D. An example of an HTML page with the main element being given a background-color of hsl(39, 100%, 65%)You can also find color pickers online for HSL colors.Property name short-handYou can also set the background color using the short-hand background property.p {

background: pink;

}

body {

background: black;

}

div {

background: rgb(139,0,0);

}

h1 {

background: #FF4500;

}

main {

background: hsl(39,100%,65%);

}The same CSS properties seen before, but with the background shorthand property.An example of an HTML page with all the elements being given a background color.This is a more versatile property, as it is shorthand for various background properties, like background-image and background-position. When you use it with a color value it works exactly the same as background-color.ConclusionYou have learned how to give a background color to your HTML elements using the background-color property and its shorthand background, and using different color notations. Now you have all the tools you need to add whatever colors you want to your web pages. Enjoy!AppendixAll 140+ named colorsSpelling VariationsThe color names containing the word "Gray" can also be written with the spelling "Grey" as shown below.

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Ilenia Magoni

Moderator and staff author for freeCodeCamp.

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTISEMENT

freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546)

Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public.

Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.

You can make a tax-deductible donation here.

Trending Guides

Delete File in Linux

What is :: in Python?

Python PWD Equivalent

JSONObject.toString()

What is SSH in Linux?

Max int Size in Python

Python Bytes to String

Git Pull Remote Branch

Fix Git Merge Conflicts

JavaScript Refresh Page

Git Revert

JSON Comments

Java Use Cases

Python Copy File

Linux cp Command

Python list.pop()

JS Sum of an Array

Python Split String

HTTP Request Methods

Compare Strings in C

What Does $ Mean in JS?

Python range() Function

Pandas Iterate Over Rows

Initialize a List in Java

Check for Empty String JS

Initialize ArrayList Java

Delete Environment in Conda

Pretty Print JSON in Python

What Does $ Mean in Python?

Check for Empty List Python

Mobile App

Our Charity

About

Alumni Network

Open Source

Shop

Support

Sponsors

Academic Honesty

Code of Conduct

Privacy Policy

Terms of Service

Copyright Policy

HTML Background Color — HTML Color Codes

HTML Background Color — HTML Color Codes

HTML Color Codes

Picker

Convert

RGB to Hex

Hex to RGB

Chart

Names

HTML Color Names

Minecraft Color Codes

Bukkit Color Codes

Roblox Color Codes

Library

Tutorials

Resources

Font Generator

Picker

Convert

RGB to Hex

Hex to RGB

Chart

Names

HTML

Minecraft

Bukkit

Roblox

Library

Tutorials

Resources

Dixon & Moe

Email

HTML Tutorial

HTML Background Color

Websites today are bolder and brighter than ever, and with this quick tutorial you too can learn how to brighten up your website with some HTML background color magic, using Hex color codes, HTML color names, RGB and HSL values.

Background color using Hex color codes

Coloring a webpage background is actually pretty simple. The first and most popular way is by using a Hex color code with the background-color property. Here we apply a Hex color directly on the HTML element using the style attribute.

HTML

Demo on CodePen

This same method can be used to style just about any HTML element, but keep in mind their behavior may differ depending on whether they are inline or block level elements. Use our color picker or color charts to find a Hex color code.

Background color using HTML color names

HEX color codes may be the most popular, but they are just one of many methods available to color an HTML element. A second way is to use an HTML color name; simply replace the HEX code with one of the 140 supported color names and you're good to go.

HTML

Demo on CodePen

Here is a helpful list of all 140 HTML color names with their corresponding HEX and RGB values for reference.

Background color using RGB color values

RGB values can also be used to add a background color to HTML elements. Using the same style attribute like before, replace the HEX code or color name with a properly formatted RGB value (be sure to enclose it in parentheses and prefix it with a lowercase 'rgb').

HTML

Demo on CodePen

When using RGB values in HTML you have the additional option of specifying the level of opacity. With the prefix rgba() – the 'a' stands for alpha, the channel that controls transparency – you can insert a fourth value between 0 and 1, 0 for fully transparent and 1 for totally opaque (use decimal values for levels in between).

HTML

Demo on CodePen

Background color using HSL color values

Less popular but equally as powerful, HSL values are now supported by many modern browsers. If you're unfamiliar with HSL (which stands for Hue, Saturation and Lightness) head on over to Wikipedia for a rundown of why they're so awesome. If you just want to use them for an HTML background color, follow the same syntax as the RGB values above, but using instead the hsl() prefix.

HTML

Demo on CodePen

Like their RGB brethren, HSL can also be passed an alpha channel to control the opacity. Use the hsla() prefix and insert a fourth value between 0 and 1.

HTML

Demo on CodePen

Share HTML background color with your friends!

Tweet

Post

Share

Pin

HTML Color Codes

Tutorials

HTML Background Color

English

English

Español

Français

中国

Designed By

Dixon & Moe

© 2015 – 2023

Privacy Policy

Privacy Manager

Contact

Email

Socialize

Google+

Facebook

CodePen

About

We built HTML Color Codes because we believe tools for design should be well designed themselves. If you like the site or have a suggestion, drop us a line; feedback is very much appreciated and always welcome!

Partner Sites

Lorem Ipsum

Word Counter

Glyphy

Colophon

Middleman

Highlight.js

ColorJoe.js

ColorHarmony.js

HTML Background Color Tutorial – How to Change a Div Background Color, Explained with Code Examples

HTML Background Color Tutorial – How to Change a Div Background Color, Explained with Code Examples

Search

Submit your search query

Forum

Donate

May 7, 2020

/

#CSS

HTML Background Color Tutorial – How to Change a Div Background Color, Explained with Code Examples

Sarah Chima Atuonwu

One of the most common things you may have to do as a web developer is to change the background-color of an HTML element. But it may be confusing to do if you do not understand how to use the CSS background-color property. In the article, we discuss the default background color value of an HTML element how to change the background color of a div, which is a very common elementwhich parts of the CSS box model are affected by the background-color property, andthe different values this property can take. Default Background Color of an ElementThe default background color of  a div is transparent. So if you do not specify the background-color of a div, it will display that of its parent element.Changing the Background Color of a DivIn this example, we will change the background colors of the following divs.

I love HTML

I love CSS

I love JavaScript

Without any styling, this will translate to the following visually. Let's change the background color of the divs by adding styles to the classes. You can follow along by trying the examples in an HTML file.

I love HTML

I love CSS

I love JavaScript

This will result in the following:Cool! We have successfully changed the background color of this div. Next, let's get to know more about this property. Let's see how the background-color property affects parts of the CSS-box model.Background Color and the CSS Box ModelAccording to the CSS box model, all HTML elements can be modeled as rectangular boxes. Every box is composed of 4 parts as shown in the diagram below. The CSS Box ModelYou can read up on the box model if you are not familiar with it. The question is, which part of the box model is affected when you change the background color of a div? The simple answer is the padding area and the content area. Let's confirm this by using an example.

This is the parent div which contains the div we are testing

This example shows that changing the background color of a div does not affect the border and margin of the div.

This will result in:From the example above, we can see that the margin area and the border area are not affected by the change in background color. We can change the color of the border using the border-color property. The margin area remains transparent and reflects the background color of the parent container. Finally, let's discuss the values the background-color property can take.Background-color ValuesJust like the color property, the background-color property can take six different values. Let's consider the three most common values with an example. In the example, we set the background-color of the div to red with different values.

The background property can take six different values.

The background property can take six different values.

The background property can take six different values.

Notice that they all result with the same background color. Other values the background-color property can take include HSL value, special keyword values and global values. Here are examples of each of them./* HSL value */

background-color: hsl(0, 100%, 25%;

/* Special keyword values */

background-color: currentcolor;

background-color: transparent;

/* Global values */

background-color: inherit;

background-color: initial;

background-color: unset;

You can read more on each of these values here.Extra NoteWhen setting the background color of an element, it is important to ensure that the contrast ratio of the background color and the color of the text it contains is high enough. This is to ensure that people with low vision can easily read the text. Consider these two divs.The contrast between the background color of the first div and the color of the text is not high enough for everyone to see. So unless you are the only one using the website you are building and you have very good eyesight, you should avoid such color combinations. The second div has a much better contrast ratio between the background color and the color of the text . Thus, it is more accessible and clearer for people to read.ConclusionIn this article, we saw how you can change the background-color of a div. We also discussed which parts of the CSS box model are affected by the change in background-color. Finally, we discussed the values the background-color property can take. I hope you found this article useful. Thanks for reading.

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Sarah Chima Atuonwu

I am a software engineer that is interested in making the web accessible for all. I love sharing knowledge so I write about things I learn and things I need to learn.

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTISEMENT

freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546)

Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons - all freely available to the public.

Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.

You can make a tax-deductible donation here.

Trending Guides

Delete File in Linux

What is :: in Python?

Python PWD Equivalent

JSONObject.toString()

What is SSH in Linux?

Max int Size in Python

Python Bytes to String

Git Pull Remote Branch

Fix Git Merge Conflicts

JavaScript Refresh Page

Git Revert

JSON Comments

Java Use Cases

Python Copy File

Linux cp Command

Python list.pop()

JS Sum of an Array

Python Split String

HTTP Request Methods

Compare Strings in C

What Does $ Mean in JS?

Python range() Function

Pandas Iterate Over Rows

Initialize a List in Java

Check for Empty String JS

Initialize ArrayList Java

Delete Environment in Conda

Pretty Print JSON in Python

What Does $ Mean in Python?

Check for Empty List Python

Mobile App

Our Charity

About

Alumni Network

Open Source

Shop

Support

Sponsors

Academic Honesty

Code of Conduct

Privacy Policy

Terms of Service

Copyright Policy

How to Set Background Color in HTML & CSS

How to Set Background Color in HTML & CSS

Skip to ContentQuizzesPRO

Courses

Guides

New

Tech Help Pro

Expert Videos

About wikiHow Pro

Upgrade

Sign In

QUIZZESEDIT

Edit this Article

EXPLORE

Tech Help ProAbout UsRandom ArticleQuizzes

Request a New ArticleCommunity DashboardThis Or That Game

Popular Categories

Arts and EntertainmentArtworkBooksMoviesComputers and ElectronicsComputersPhone SkillsTechnology HacksHealthMen's HealthMental HealthWomen's HealthRelationshipsDatingLoveRelationship Issues

Hobbies and CraftsCraftsDrawingGamesEducation & CommunicationCommunication SkillsPersonal DevelopmentStudyingPersonal Care and StyleFashionHair CarePersonal HygieneYouthPersonal CareSchool StuffDating

All Categories

Arts and EntertainmentFinance and BusinessHome and GardenRelationship Quizzes

Cars & Other VehiclesFood and EntertainingPersonal Care and StyleSports and Fitness

Computers and ElectronicsHealthPets and AnimalsTravel

Education & CommunicationHobbies and CraftsPhilosophy and ReligionWork World

Family LifeHolidays and TraditionsRelationshipsYouth

LOG IN

Log in

Social login does not work in incognito and private browsers. Please log in with your username or email to continue.

Facebook

Google

wikiHow Account

No account yet? Create an account

RANDOMHomeRandomBrowse ArticlesLearn Something NewGuidesCoursesQuizzesHotPlay GamesThis Or That GameNewTrain Your BrainExplore MoreSupport wikiHowAbout wikiHowLog in / Sign upTerms of Use

wikiHow is where trusted research and expert knowledge come together. Learn why people trust wikiHow

CategoriesComputers and ElectronicsInternetWebsite and Blog CreationMarkup LanguagesHTML3 Methods to Set a Background Color with HTML & CSS

Download Article

An easy-to-follow guide for coding with CSS and HTML to add the background colors of a page

Written by

Jessica Andzouana

|

Edited by

Darlene Antonelli, MA

Last Updated: February 2, 2024

Fact Checked

Download Article

Setting a Solid Background Color

|Creating a Gradient Background

|Creating a Changing Background

|Expert Interview

|Q&A

|Tips

|Warnings

|Show more

|Show less

X

This article was written by Jessica Andzouana and by wikiHow staff writer, Darlene Antonelli, MA. Jessica Andzouana is a Software Engineer based in the San Francisco Bay Area. With over five years of professional experience in front-end development, digital art, and design, she is passionate about emerging technologies such as blockchain and AI. Her background as both a programmer and artist, paired with a highly design-conscious mindset, provides her a fresh perspective and unique skill set to produce creative solutions in her field. She works at Alcacruz as a Software Engineer, and received a dual BS/BA degree from Santa Clara in Computer Science and Studio Art.

This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.

This article has been viewed 1,515,248 times.

Did you want to change the background color of that page using HTML? Unfortunately, with HTML 5, this is no longer possible in just HTML coding. Instead, you'll need to use both HTML and CSS coding, which works even better. This wikiHow teaches you how to change the background color of a web page by editing its HTML and CSS.

Things You Should Know

Although the attribute for HTML to manage background color is gone, you can still use HTML with CSS to change your background color easily.

You'll need a numeric code for the color you want if you want a specific color. If you don't need a specific color, you can use words like "orange" or "light blue."

When editing a web page with HTML and CSS, you can create a solid background, gradient, or changing background.

Steps

Method 1

Method 1 of 3:

Setting a Solid Background Color

Download Article

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/b\/bf\/2609629-1-3.jpg\/v4-460px-2609629-1-3.jpg","bigUrl":"\/images\/thumb\/b\/bf\/2609629-1-3.jpg\/v4-728px-2609629-1-3.jpg","smallWidth":460,"smallHeight":342,"bigWidth":728,"bigHeight":541,"licensing":"

Image by: Uploader
\nLicense: Creative Commons<\/a>\n<\/p><\/div>"}

1

Find your document's "html" header. It should be near the top of the document.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/0\/02\/2609629-2-3.jpg\/v4-460px-2609629-2-3.jpg","bigUrl":"\/images\/thumb\/0\/02\/2609629-2-3.jpg\/v4-728px-2609629-2-3.jpg","smallWidth":460,"smallHeight":344,"bigWidth":728,"bigHeight":545,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

2

Add the "background-color" property to the "body" element. Type background-color: between the body brackets. You should now have the following "body" element:

body {

background-color:

}

In this context, only one spelling of "color" will work; you can't use "colour" here.

Advertisement

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/8\/8f\/2609629-3-3.jpg\/v4-460px-2609629-3-3.jpg","bigUrl":"\/images\/thumb\/8\/8f\/2609629-3-3.jpg\/v4-728px-2609629-3-3.jpg","smallWidth":460,"smallHeight":342,"bigWidth":728,"bigHeight":542,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

3

Add your desired background color to the "background-color" property. Type your selected color's numeric code followed by a semicolon next to the "background-color:" element to do so. For example, to set your page's background to pink, you would have the following:

body {

background-color: #d24dff;

}

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/b\/be\/2609629-4-3.jpg\/v4-460px-2609629-4-3.jpg","bigUrl":"\/images\/thumb\/b\/be\/2609629-4-3.jpg\/v4-728px-2609629-4-3.jpg","smallWidth":460,"smallHeight":349,"bigWidth":728,"bigHeight":552,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

4

Review your "style" information. At this point, your HTML document's header should resemble the following:

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/c\/c8\/2609629-5-3.jpg\/v4-460px-2609629-5-3.jpg","bigUrl":"\/images\/thumb\/c\/c8\/2609629-5-3.jpg\/v4-728px-2609629-5-3.jpg","smallWidth":460,"smallHeight":346,"bigWidth":728,"bigHeight":548,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

5

Use "background-color" to apply background colors to other elements. Just as you set it in the body element, you can use "background-color" to define the backgrounds of other elements such as headers, paragraphs, and so on. For example, to apply a background color to a main header (

) or a paragraph (

), you would have something resembling the following code:[1]

X

Research source

Header with Green Background

Paragraph with white background

Advertisement

Method 2

Method 2 of 3:

Creating a Gradient Background

Download Article

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/f\/f4\/2609629-6-3.jpg\/v4-460px-2609629-6-3.jpg","bigUrl":"\/images\/thumb\/f\/f4\/2609629-6-3.jpg\/v4-728px-2609629-6-3.jpg","smallWidth":460,"smallHeight":344,"bigWidth":728,"bigHeight":545,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

1

Find your document's "html" header. It should be near the top of the document.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/f\/fd\/2609629-7-3.jpg\/v4-460px-2609629-7-3.jpg","bigUrl":"\/images\/thumb\/f\/fd\/2609629-7-3.jpg\/v4-728px-2609629-7-3.jpg","smallWidth":460,"smallHeight":348,"bigWidth":728,"bigHeight":551,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

2

Understand the basic syntax of this process. When making a gradient, there are two pieces of information you'll need: the starting point/angle, and the colors that the gradient will transition between. You can select multiple colors to have the gradient move between all of them, and you can set a direction or angle for the gradient.[2]

X

Research source

background: linear-gradient(direction/angle, color1, color2, color3, etc);

}}

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/2\/21\/2609629-8-4.jpg\/v4-460px-2609629-8-4.jpg","bigUrl":"\/images\/thumb\/2\/21\/2609629-8-4.jpg\/v4-728px-2609629-8-4.jpg","smallWidth":460,"smallHeight":342,"bigWidth":728,"bigHeight":542,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

3

Make a vertical gradient. If you don't specify the direction, the gradient will go from top to bottom. To create your gradient, add the following code between the tags:

html {

min-height: 100%; }

body {

background: -webkit-linear-gradient(#93B874, #C9DCB9);

background: -o-linear-gradient(#93B874, #C9DCB9);

background: -moz-linear-gradient(#93B874, #C9DCB9);

background: linear-gradient(#93B874, #C9DCB9);

background-color: #93B874; }

Different browsers have different implementations of the gradient function, so you'll have to include several versions of the code.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/8\/8d\/2609629-9-3.jpg\/v4-460px-2609629-9-3.jpg","bigUrl":"\/images\/thumb\/8\/8d\/2609629-9-3.jpg\/v4-728px-2609629-9-3.jpg","smallWidth":460,"smallHeight":346,"bigWidth":728,"bigHeight":547,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

4

Make a directional gradient. If you'd rather create a gradient that isn't strictly vertical, you can add direction to the gradient in order to change the way the color shift appears. Do so by typing the following in between the tags:[3]

X

Research source

html {

min-height: 100%;}

body {

background: -webkit-linear-gradient(left, #93B874, #C9DCB9);

background: -o-linear-gradient(right, #93B874, #C9DCB9);

background: -moz-linear-gradient(right, #93B874, #C9DCB9);

background: linear-gradient(to right, #93B874, #C9DCB9);

background-color: #93B874; }

You can play around with the "left" and "right" tags to experiment with different directions for your gradient.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/7\/7d\/2609629-10-3.jpg\/v4-460px-2609629-10-3.jpg","bigUrl":"\/images\/thumb\/7\/7d\/2609629-10-3.jpg\/v4-728px-2609629-10-3.jpg","smallWidth":460,"smallHeight":341,"bigWidth":728,"bigHeight":540,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

5

Use other properties to adjust the gradient. There's a lot more that you can do with gradients.

For example, not only can you add more than two colors, you can also put a percentage after each one. This will allow you to set how much spacing you want each color segment to have. Here's a sample gradient that uses this principle:

background: linear-gradient(#93B874 10%, #C9DCB9 70%, #000000 90%);

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/6\/6e\/2609629-11-3.jpg\/v4-460px-2609629-11-3.jpg","bigUrl":"\/images\/thumb\/6\/6e\/2609629-11-3.jpg\/v4-728px-2609629-11-3.jpg","smallWidth":460,"smallHeight":342,"bigWidth":728,"bigHeight":541,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

6

Add transparency to your colors. This will make the color fade. Use the same color to fade from the color to nothing. You'll need to use the rgba() function to define the color. The ending value determines the transparency: 0 for solid and 1 for transparent.

background: linear-gradient(to right, rgba(147,184,116,0), rgba(147,184,116,1));

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/5\/5a\/2609629-12-3.jpg\/v4-460px-2609629-12-3.jpg","bigUrl":"\/images\/thumb\/5\/5a\/2609629-12-3.jpg\/v4-728px-2609629-12-3.jpg","smallWidth":460,"smallHeight":346,"bigWidth":728,"bigHeight":548,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

7

Review your completed code. The code to create a color gradient as your website's background will look something like this:

Advertisement

Method 3

Method 3 of 3:

Creating a Changing Background

Download Article

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/c\/c9\/2609629-13-3.jpg\/v4-460px-2609629-13-3.jpg","bigUrl":"\/images\/thumb\/c\/c9\/2609629-13-3.jpg\/v4-728px-2609629-13-3.jpg","smallWidth":460,"smallHeight":347,"bigWidth":728,"bigHeight":549,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

1

Find your document's "html" header. It should be near the top of the document.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/e\/ea\/2609629-14-3.jpg\/v4-460px-2609629-14-3.jpg","bigUrl":"\/images\/thumb\/e\/ea\/2609629-14-3.jpg\/v4-728px-2609629-14-3.jpg","smallWidth":460,"smallHeight":344,"bigWidth":728,"bigHeight":544,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

2

Add the animation property to the "body" element. Type the following into the space below the "body {" bracket and above the closing bracket:

-webkit-animation: colorchange 60s infinite;

animation: colorchange 60s infinite;

The top line of text is for Chromium-based browsers while the bottom line of text is for other browsers.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/9\/99\/2609629-15-3.jpg\/v4-460px-2609629-15-3.jpg","bigUrl":"\/images\/thumb\/9\/99\/2609629-15-3.jpg\/v4-728px-2609629-15-3.jpg","smallWidth":460,"smallHeight":345,"bigWidth":728,"bigHeight":546,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

3

Add your colors to the animation. Now you'll use the @keyframes rule to set the background colors through which you'll cycle, as well as the length of time each color will appear on the page. Again, you'll need separate entries for the different sets of browsers. Enter the following lines of code below the closed "body" bracket:[4]

X

Research source

@-webkit-keyframes colorchange {

0% {background: #33FFF3;}

25% {background: #78281F;}

50% {background: #117A65;}

75% {background: #DC7633;}

100% {background: #9B59B6;}

}

@keyframes colorchange {

0% {background: #33FFF3;}

25% {background: #78281F;}

50% {background: #117A65;}

75% {background: #DC7633;}

100% {background: #9B59B6;}

}

Note that the two rules (@-webkit-keyframes and @keyframes have the same background colors and percentages. You'll want these to stay uniform so the experience is the same on all browsers.

The percentages (0%, 25%, etc) are of the total animation length (60s). When the page loads, the background will be the color set at 0% (#33FFF3). Once the animation has played for 25% of of 60 seconds, the background will turn to #7821F, and so on.

You can modify the times and colors to fit your desired outcome.

{"smallUrl":"https:\/\/www.wikihow.com\/images\/thumb\/1\/18\/2609629-16-3.jpg\/v4-460px-2609629-16-3.jpg","bigUrl":"\/images\/thumb\/1\/18\/2609629-16-3.jpg\/v4-728px-2609629-16-3.jpg","smallWidth":460,"smallHeight":342,"bigWidth":728,"bigHeight":542,"licensing":"

Image by: Uploader
\nLicense:
Creative Commons<\/a>\n<\/p><\/div>"}

4

Review your code. Your entire code for the changing background color should resemble the following:

Advertisement

Community Q&A

Search

Add New Question

Question

How do I set a background color for a specific width?

Community Answer

Use the background-size property inside of the "body" element. For example, "background-size: 300px 150px" makes the background 300 pixels wide and 150 pixels high.

Thanks! We're glad this was helpful.

Thank you for your feedback.

If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.

Support wikiHow

Yes

No

Not Helpful 15

Helpful 35

Question

It does not work. What can I do?

UsernameHere11

Community Answer

To make it black, try:

body {

background-color: #190707}

Thanks! We're glad this was helpful.

Thank you for your feedback.

If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.

Support wikiHow

Yes

No

Not Helpful 21

Helpful 20

Question

What is the correct HTML for adding a background color?

Community Answer

My text goes here!

Replace the html code above with your text and selected your preferred color.

Thanks! We're glad this was helpful.

Thank you for your feedback.

If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission.

Support wikiHow

Yes

No

Not Helpful 32

Helpful 30

See more answers

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Submit

Advertisement

Tips

Use online HTML pickers if you want a very specific color for your background. If, for example, you want the background to be the same color as your walls, you can match HTML colors with paint splotches at certain sites.

Thanks

Helpful

0

Not Helpful

0

If you want to use basic colors within your HTML code, you can type the colors' names without the pound sign (#) instead of using an HTML color code. For example: to create an orange background, you would type in background-color: orange; here.

Thanks

Helpful

0

Not Helpful

0

You can also set a an image as your website's background with HTML.

Thanks

Helpful

0

Not Helpful

0

Submit a Tip

All tip submissions are carefully reviewed before being published

Submit

Thanks for submitting a tip for review!

Advertisement

Warnings

Make sure you test any changes to your website before publishing them online.

Thanks

Helpful

2

Not Helpful

0

Advertisement

You Might Also Like

How toUse Font Color Tags in HTML

How to Change Text Color in HTML and CSS

How toCreate a Simple CSS Stylesheet Using Notepad

How toCreate a Simple Web Page with HTML

How toInsert Spaces in HTML

How toRun a HTML File in Visual Studio Code

4 Ways to Add a Link to a Picture

How toChange the Button Color in HTML

How toGet the Hex Code of a Color on Your Computer Screen

How toWrite HTML Code

How toCreate an Email Link in HTML

How toRun a HTML File

How toInsert Images with HTML

Add a Background Image to a Website: Step-by-Step Tutorial

Advertisement

Expert Interview

Thanks for reading our article! If you’d like to learn more about dealing with html, check out our in-depth interview with Jessica Andzouana.

References

↑ http://www.w3schools.com/css/css_background.asp

↑ https://css-tricks.com/css3-gradients/

↑ http://www.w3schools.com/css/css3_gradients.asp

↑ http://www.w3schools.com/css/css3_animations.asp

About This Article

Written by:

Jessica Andzouana

Software Engineer

This article was written by Jessica Andzouana and by wikiHow staff writer, Darlene Antonelli, MA. Jessica Andzouana is a Software Engineer based in the San Francisco Bay Area. With over five years of professional experience in front-end development, digital art, and design, she is passionate about emerging technologies such as blockchain and AI. Her background as both a programmer and artist, paired with a highly design-conscious mindset, provides her a fresh perspective and unique skill set to produce creative solutions in her field. She works at Alcacruz as a Software Engineer, and received a dual BS/BA degree from Santa Clara in Computer Science and Studio Art. This article has been viewed 1,515,248 times.

How helpful is this?

Co-authors: 36

Updated: February 2, 2024

Views: 1,515,248

Categories: Featured Articles | HTML

In other languages

Français:mettre une couleur de fond de page en HTML

Español:establecer el color de fondo en HTML

Bahasa Indonesia:Memasang Warna Latar Belakang HTML

Русский:задать цвет фона в HTML

Deutsch:In HTML die Hintergrundfarbe festlegen

Português:Configurar Cores de Fundo em HTML

Italiano:Impostare il Colore di Sfondo in HTML

ไทย:เปลี่ยนสีพื้นหลังเว็บด้วย HTML

Nederlands:De achtergrondkleur in HTML aanpassen

العربية:إدراج لون خلفية في لغة الترميز HTML

Tiếng Việt:Thiết lập màu nền trong HTML

日本語:HTMLで背景色を指定する

中文:在HTML中设置网页背景颜色

한국어:HTML 배경색 바꾸는 방법

हिन्दी:HTML में बैकग्राउंड कलर सेट करें (Set Background Color in HTML)

Türkçe:HTML'de Arka Plan Rengi Nasıl Ayarlanır

فارسی:رنگ پس‌زمینه‌ی HTML را تنظیم کنیم

Print

Send fan mail to authors

Thanks to all authors for creating a page that has been read 1,515,248 times.

Reader Success Stories

Gab G.

Aug 30, 2017

"Thanks, this is exactly what I was looking for, very clear. I can copy the code as well and it took me like 20 seconds to get exactly the result I wanted, thanks to this tutorial!"..." more

More reader stories

Hide reader stories

Share your story

Is this article up to date?

Yes

No

Advertisement

Cookies make wikiHow better. By continuing to use our site, you agree to our cookie policy.

Written by:

Jessica Andzouana

Software Engineer

Click a star to vote

% of people told us that this article helped them.

Co-authors: 36

Updated: February 2, 2024

Views: 1,515,248

Gab G.

Aug 30, 2017

"Thanks, this is exactly what I was looking for, very clear. I can copy the code as well and it took me like 20 seconds to get exactly the result I wanted, thanks to this tutorial!"..." more

Anonymous

Dec 4, 2016

"Helped by putting a background color on note++. Thanks a lot wikiHow."

Bernadette Arguelles

Oct 3, 2016

"How to set a background color in HTML was helpful."

Jay Sonekar

Nov 5, 2017

"Very helpful, thanks to all those who wrote it."

Azam Khan

Apr 24, 2017

"I like this because of the code of colors."

Share yours!

More success stories

Hide success stories

QuizzesAm I a Narcissist or an Empath QuizTake QuizDoes He Like Me QuizTake QuizWhat Is My Aesthetic QuizTake QuizAm I Gay QuizTake QuizWhy Can't I Sleep QuizTake QuizZodiac Compatibility QuizTake Quiz

You Might Also LikeHow toUse Font Color Tags in HTMLHow to Change Text Color in HTML and CSSHow toCreate a Simple CSS Stylesheet Using NotepadHow toCreate a Simple Web Page with HTML

Featured ArticlesHow toEnjoy Your Early Teen YearsHow toMake Your School More Period FriendlyHow to Prepare for Your Classes: Tips for Creating a Study TimetableHow to Redo Rock LandscapingHow toMingle With Strangers at PartiesWhat Does It Mean When Your Left Ear Rings? 5 Spiritual InterpretationsTrending ArticlesHow toIntroduce Friends to Other FriendsHow toEstimate Distances (by Using Your Thumb and Eyes)Am I Manipulative QuizHow Do You Know if Your Avoidant Partner Loves You?Which Powerpuff Girl Am I QuizHow toMake Natural DyesFeatured ArticlesHow to Find the Name of a Song without Knowing the LyricsHow toSave MoneyHow toTeachHow toUnderstand Your PersonalityHow to Stop a Dog from Jumping Up on PeopleHow toStrengthen CharacterFeatured ArticlesAlways Win at Connect 4: The Strategy That Will Keep You on TopLoving Yourself: Simple and Easy Ways to Practice Self-Love Every Day10 Easy Ways to Keep Earbuds from Falling Out of Your EarsHow toGain Control of Your EmotionsHow to Make Your Phone Harder to TrackHow to Dance: Smooth and Simple Moves for Any OccasionWatch ArticlesAerating Wine: Benefits, the Breakdown, & Which Wines You Can Skip4 Simple Ways to Fold or Roll a WrapHow toMake a Stress Ball with SlimeHow toMake Nutella Hot ChocolateHow toClean a Charger PortHow toBleach JeansTrending ArticlesHow toMake Your Feet BeautifulHow to Use the Push-Pull TechniqueHow to Make Friends in Your 20s after CollegeYes, You Can Shrink Polyester, and Here’s HowHow to Tell If Your Ex Is Manifesting You: 15 Powerful Signs How toReinvent Yourself After a Break Up (Girls)

CategoriesComputers and ElectronicsInternetWebsite and Blog CreationMarkup LanguagesHTML

wikiHow Newsletter

You're all set!

Helpful how-tos delivered toyour inbox every week!

Sign me up!

By signing up you are agreeing to receive emails according to our privacy policy.

Home

About wikiHow

Experts

Jobs

Contact Us

Site Map

Terms of Use

Privacy Policy

Do Not Sell or Share My Info

Not Selling Info

Contribute

Follow Us

×

wikiHow Tech Help Pro:

Level up your tech skills and stay ahead of the curve

Let's go!

X

--653