Recall & Review
beginner
What is a CSS selector?
A CSS selector is a pattern used to select and style HTML elements on a web page.
Click to reveal answer
beginner
How do you select an element by its ID using CSS selector syntax?
Use the hash symbol (#) followed by the element's ID. For example,
#header selects the element with id="header".Click to reveal answer
beginner
How do you select elements by their class name?Use a dot (.) followed by the class name. For example, <code>.button</code> selects all elements with class="button".Click to reveal answer
intermediate
What does the selector
div > p select?It selects all
<p> elements that are direct children of a <div> element.Click to reveal answer
intermediate
How do you select elements with a specific attribute value?
Use square brackets with the attribute and value inside. For example,
input[type='text'] selects all <input> elements with type="text".Click to reveal answer
Which CSS selector selects all elements with class 'menu'?
✗ Incorrect
The dot (.) before 'menu' selects elements by class name.
What does the selector
ul li select?✗ Incorrect
A space between selectors means any descendant, so all inside
- .
How do you select an element with id 'main'?
✗ Incorrect
The hash (#) selects elements by their id attribute.
What does
a[href^='https'] select?✗ Incorrect
The ^= attribute selector matches attribute values that start with the given string.
Which selector matches all direct child <p> elements of a <div>?
✗ Incorrect
The > combinator selects direct children only.
Explain how to select elements by ID, class, and attribute using CSS selectors.
Think about the symbols used before the names.
You got /3 concepts.
Describe the difference between the selectors 'div p' and 'div > p'.
One selects all nested, the other only immediate children.
You got /3 concepts.