How to use bgColor Attribute In HTML

In HTML, you can change the background color of an element using the bgcolor attribute. This approach involves directly adding the bgcolor attribute to the HTML element and specify the desired background color.

Syntax:

<tagname bgcolor="color">

Example: Implementation to change the background colour.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>Using bgcolor attribute</title>
 
</head>
 
<body bgcolor="grey">
    <h1>w3wiki</h1>
    <h3>
        Using bgColor attribute for Background change
    </h3>
</body>
 
</html>


Output:

Note: Only one approach is possible for changing the background color of HTML without using CSS. However we can change the background color of HTML using below approaches also.

How to Change Background Color in HTML without CSS ?

In HTML, you can change the background color of an element using the bgcolor attribute. However, it’s important to note that the bgcolor attribute is deprecated in HTML5 and should be avoided in favor of using CSS for styling.

Table of Content

  • Using bgColor Attribute
  • Using Inline Styling
  • Using JavaScript
  • Using Internal CSS

Similar Reads

Using bgColor Attribute

In HTML, you can change the background color of an element using the bgcolor attribute. This approach involves directly adding the bgcolor attribute to the HTML element and specify the desired background color....

Using Inline Styling

...

Using JavaScript

In HTML, you can change the background color of an element using inline styling. This approach involves directly adding the `style` attribute to the HTML element and specifying the desired background colour using the ‘background-colour’ property....

Using Internal CSS

...

Contact Us