0% found this document useful (0 votes)
13 views

Program 2

There are three methods to change the background color of an HTML document: 1. Using the bgcolor attribute in the <BODY> tag 2. Using inline CSS within the <style> tags in the <HEAD> section 3. Using internal CSS by adding a style attribute to the <BODY> tag Each method is demonstrated with an example HTML code using different background colors like lightgreen and greenyellow.

Uploaded by

Vanshika Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Program 2

There are three methods to change the background color of an HTML document: 1. Using the bgcolor attribute in the <BODY> tag 2. Using inline CSS within the <style> tags in the <HEAD> section 3. Using internal CSS by adding a style attribute to the <BODY> tag Each method is demonstrated with an example HTML code using different background colors like lightgreen and greenyellow.

Uploaded by

Vanshika Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2.

Write a program in HTML using background colour and


text colour?
There are three methods to change the background color of a document:
 Using bgcolor attribute
 Using Inline CSS
 Using Internal Stylesheet

<BODY bgcolor=”colorname”>
For example: <BODY bgcolor=”green”> or <BODY bgcolor=”blue”>

Method 1: Using bgcolor attribute

HTML provides various styles and attributes to make changes to the documents as
per the user’s needs. Following is an HTML code that shows the use
of bgcolor attribute:

<html >
<head>
<title>Document</title>
</head>
<body bgcolor="lightgreen" >
<h1>Hello reader my name is sachin Welcome to GeekforGeeks</h1>
</body>
</html>

Method 2: Using an Inline style attribute


If we want to change the color of a background of a web page using an inline style
attribute, we have to follow the steps which are given below. We can easily change
the color of the background from the following code:
<html >
<head>
<title>Internal CSS</title>
<style>
Body
{
background-color:greenyellow;
}
</style>
</head>
<body>
<h1>Welcome to GeeksforGeeks</h1>
<h2>We are using the Internal CSS</h2>
</body>
</html>

Method 3: Using internal CSS

If we want to change the color of a background of a web page using an internal


cascading stylesheet, we have to follow the steps which are given below. We can
easily change the background color from the following code:
<html lang="en">
<head>
<title>inline style attribute</title>
</head>
<body style="background-color:greenyellow">
<h1>Welcome to GeeksforGeeks</h1>
<h2>We are using the inline style attribute</h2>
</body>
</html>

You might also like