Very Short Question and Answers - Color and Background
Ans:
The color property is used to change the text color of HTML elements.
Ans:
The color property can be applied to paragraphs, headings, links, and any text-containing element.
Ans:
selector { color: value; }
Ans:
Named colors (e.g., red, blue), hexadecimal (e.g., #ff0000), and RGB (e.g., rgb(255, 0, 0)).
Ans:
Class 10 usually focuses on named colors.
Ans:
The background-color property sets the background color of an element, which appears behind the content like text or images.
Ans:
It can be applied to the entire webpage (body), headings, paragraphs, divisions (<div>), and table cells.
Ans:
selector { background-color: value; }
Ans:
p { color: blue; }
Ans:
h1 { background-color: green; }
Ans:
h2 { color: red; background-color: yellow; }
Ans:
It sets paragraph text color to white and its background color to black.
Ans:
Each property must end with a semicolon to separate properties and ensure proper CSS syntax.
Ans:
Curly braces { } enclose the set of style declarations for a CSS selector.
Ans:
Yes, both can be used together to set the text color and the background color of an element simultaneously.
Ans:
color changes the text color while background-color changes the background behind the content.
Ans:
h2 { color: #00ff00; } changes the text color of h2 to green using a hex code.
Ans:
The text color will become blue.
Ans:
To change the background color of the entire webpage, use: body { background-color: lightblue; }
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; }