CSS (Fundamentals, Colors, and Styling) 2 — Questions and Answers
Question 1: Which CSS property is used to change the text color of an element?
- color (Correct answer)
- text-color
- font-color
- foreground
Correct answer: color
The 'color' property sets the foreground (text) color of an element.
Question 2: What does the hexadecimal color value #FFFFFF represent?
- Black
- Red
- White (Correct answer)
- Transparent
Correct answer: White
#FFFFFF is full intensity on all RGB channels, producing white.
Question 3: Which function lets you specify a color with an alpha (transparency) channel?
- rgb()
- rgba() (Correct answer)
- hex()
- hsl()
Correct answer: rgba()
rgba() adds a fourth alpha value (0–1) controlling opacity.
Question 4: How do you write a single-line comment in CSS?
- // comment
- <!-- comment -->
- /* comment */ (Correct answer)
- # comment
Correct answer: /* comment */
CSS uses /* */ for all comments; there is no // syntax.
Question 5: Which property controls the space between the content and the element's border?
- margin
- padding (Correct answer)
- spacing
- gap
Correct answer: padding
Padding is the inner space between content and the border.
Question 6: What is the correct CSS syntax to make all <p> elements bold?
- p {font-weight: bold;} (Correct answer)
- p {text-style: bold;}
- <p style=bold>
- p.all {weight: bold;}
Correct answer: p {font-weight: bold;}
font-weight: bold applied to the p selector bolds all paragraphs.
Question 7: In the HSL color model, what does the first value represent?
- Saturation
- Lightness
- Hue (Correct answer)
- Alpha
Correct answer: Hue
HSL stands for Hue, Saturation, Lightness, with hue measured in degrees.
Which CSS property is used to change the text color of an element?