logo

Very Short Question and Answers - Color and Background


Q 1.
What is the purpose of the `color` property in CSS?

Ans:

The color property is used to change the text color of HTML elements.

Q 2.
Which HTML elements can use the `color` property?

Ans:

The color property can be applied to paragraphs, headings, links, and any text-containing element.

Q 3.
Write the syntax for changing text color using the `color` property.

Ans:

selector { color: value; }

Q 4.
Name three types of color values that can be used with the `color` property.

Ans:

Named colors (e.g., red, blue), hexadecimal (e.g., #ff0000), and RGB (e.g., rgb(255, 0, 0)).

Q 5.
Which color values are usually focused on in Class 10 studies?

Ans:

Class 10 usually focuses on named colors.

Q 6.
What does the `background-color` property do in CSS?

Ans:

The background-color property sets the background color of an element, which appears behind the content like text or images.

Q 7.
List at least three elements where `background-color` can be applied.

Ans:

It can be applied to the entire webpage (body), headings, paragraphs, divisions (<div>), and table cells.

Q 8.
Provide the syntax to set a background color in CSS.

Ans:

selector { background-color: value; }

Q 9.
Give an example of CSS code that changes paragraph text color to blue.

Ans:

p { color: blue; }

Q 10.
How do you make an `<h1>` heading have a green background in CSS?

Ans:

h1 { background-color: green; }

Q 11.
Write CSS to make the text of an `<h2>` red and the background yellow.

Ans:

h2 { color: red; background-color: yellow; }

Q 12.
What does this CSS snippet do? `p { color: white; background-color: black; }`

Ans:

It sets paragraph text color to white and its background color to black.

Q 13.
Why must each property in CSS end with a semicolon?

Ans:

Each property must end with a semicolon to separate properties and ensure proper CSS syntax.

Q 14.
What is the significance of curly braces `{ }` in CSS?

Ans:

Curly braces { } enclose the set of style declarations for a CSS selector.

Q 15.
Can `color` and `background-color` properties be used together on the same element? Explain.

Ans:

Yes, both can be used together to set the text color and the background color of an element simultaneously.

Q 16.
Name one difference between `color` and `background-color` properties.

Ans:

color changes the text color while background-color changes the background behind the content.

Q 17.
Give an example of using a hexadecimal color value for text color.

Ans:

h2 { color: #00ff00; } changes the text color of h2 to green using a hex code.

Q 18.
What color will the text become if CSS sets `color: #0000ff;`?

Ans:

The text color will become blue.

Q 19.
Explain with an example how to change the background color of the entire webpage.

Ans:

To change the background color of the entire webpage, use: body { background-color: lightblue; }

Q 20.
Write a 2-mark answer explaining the purpose of `color` and `background-color` properties with examples.

Ans:

The color property changes the text color of an element. Example: p { color: blue; } The background-color property changes the background color of an element. Example: h1 { background-color: yellow; }