How to use Inline Styling In HTML

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.

Syntax:

<p style="background-color: yellow;">This is a paragraph</p>

Example: Implementation to change the background colour.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>Inline Styles</title>
</head>
 
<body style="background-color: green;">
    <h1>w3wiki</h1>
    <h3>Using Inline Styling for Background change</h3>
</body>
 
</html>


Output:

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