CSS (Selectors, Appearance, & Files) 3 — Questions and Answers
Question 1: Which property sets the background color of an element?
- background-color (Correct answer)
- bgcolor
- color-background
- fill
Correct answer: background-color
background-color sets the element's background fill color.
Question 2: What does the selector "input[type=\"text\"]" match?
- Input elements whose type attribute equals text (Correct answer)
- All input elements
- Elements containing the word text
- Inputs with a class named text
Correct answer: Input elements whose type attribute equals text
An attribute selector in brackets matches elements with the specified attribute value.
Question 3: Which pseudo-element styles the first line of a paragraph?
- p::first-line (Correct answer)
- p:first-line-only
- p::firstline
- p:line-first
Correct answer: p::first-line
The ::first-line pseudo-element targets the first rendered line of text.
Question 4: What is the correct way to write an inline style on an element?
- <p style="color:red"> (Correct answer)
- <p css="color:red">
- <p inline="color:red">
- <p class="color:red">
Correct answer: <p style="color:red">
Inline styles use the style attribute containing CSS declarations.
Question 5: Which property controls the typeface used for text?
- font-family (Correct answer)
- text-font
- typeface
- font-type
Correct answer: font-family
font-family specifies a prioritized list of font names.
Question 6: What does the selector "h1, h2, h3" do?
- Applies the same styles to all three heading types (Correct answer)
- Selects h3 inside h2 inside h1
- Selects only h1
- Selects elements with all three classes
Correct answer: Applies the same styles to all three heading types
Commas group selectors so one rule applies to each listed element.
Question 7: Which selector targets every <li> that is the first child of its parent?
- li:first-child (Correct answer)
- li::first
- li:first
- li.first-child
Correct answer: li:first-child
The :first-child pseudo-class matches an element that is the first child of its parent.
Which property sets the background color of an element?