Introduction
HTML stands for Hypertext Markup Language. It is a designing language that is used by the user to create and design webpages. By working with HTML one can create good-looking and appealing web pages for uploading them on a web server which then becomes available to several web surfers using the web across the globe. HTML also allows us to enhance the appearance of our web page by letting us work with not only text but also images, links, hyperlinks, etc. We can also add colours to several areas or the entire web page. HTML have various different categories of representing colours, like Hex colour codes, HTML colour names, RGB and RGBA values, HSL colours, etc.
HTML Logo
Sample Code of HTML
Changing Background Colour
While writing the contents of a Web Page we always include them inside the tag. We can change the background colour of a web page by using the bgcolor attribute provided by HTML. In HTML we have a lot of different attributes which work with the content's characteristics, thus generally modifying the behaviour of the elements. The attribute values are always written in double quotes, the Syntax is as follows.
<body bgcolor="value">
Changing the Background Colour in HTML
Syntax Used In Changing Background Colour
The main syntax for changing the background colour in HTML is:
<body bgcolor="value">
Syntax of bgcolor Attribute
We can change the background colour in more than one way:
By simply using the bgcolor attribute
Using an inline style attribute
Using internal CSS styling
List of Values in Hexadecimal Notation
While assigning the colour to the tag of the bgcolor attribute, we can either do so by specifying the hexadecimal value for the specific colour or by simply specifying the name of the colour. A (#) is put before the value when the value of the colour is specified by its hexadecimal notation.
Hexadecimal Notation in HTML
The following table states some of the important colours along with their respective values in hexadecimal notation:
Summary
While working with HTML we also have an option of changing the background colour of the web page that we are creating, we can do so by using the bgcolor attribute. We also have other options like using the inline attribute command or the CSS styling. The colours have some specific hexadecimal notations which are specified or mostly used while working with the bgcolor attribute. The values for some of the colours are given in the table above.
Sample Questions
1. How can you change the link colour for any link in HTML?
Ans: Changing the link colour when the visitor hovers over a link helps indicate what is clickable on your web page or blog. Make your page's link colour change, and implement the below code into your <head></head> portion of your HTML or in your CSS code for your web page.
2. How can we make text transparent in HTML?
Ans: There is as such no colour code for making our text transparent in HTML or in CSS, but however we can make our text appear to be transparent on a web page by setting the text colour as the same colour as that of the background colour of the webpage.
Practice Questions
1. Find the correct command syntax from the ones that follow:
<marquee bg colour: "red">
<marquee bg-colour = "red">
<marquee bgcolor = "red">
<marquee colour = "red">
Ans: c)
2. Which of the following HTML attributes is used to define inline styles?
style
type
class
None of the above
Ans: a)
3. Give the hexadecimal notations for the following colours:
White
Black
Blue
Red
Yellow
Answers:
#FFFFFF
#000000
#0000FF
#FF0000
#FFFF00
FAQs on Changing Background Colour
1. How are colours specified in HTML?
HTML colours are specified with predefined colour names, or with RGB, HEX, HSL, RGBA, or HSLA values. In HTML, a colour can be specified by using a colour name: HTML supports almost 140 standard colour names.
2. What are attributes in HTML?
An additional attribute is given to each tag to alter the behaviour of the tag. Attributes are defined directly after the tag name, inside the angular brackets. They appear in opening tags and can never appear in closing tags.
3. Where can you specify colours for table borders?
The specification of colour for table borders can be made in the style sheet, and in its absence, the same colour as the text will apply.