Recall & Review
beginner
What is an ID selector in CSS?
An ID selector targets an HTML element with a specific id attribute. It uses a
# followed by the id name to apply styles to that unique element.Click to reveal answer
beginner
How do you write an ID selector for an element with
id="header"?You write it as
#header in your CSS. For example:<br>#header { background-color: lightblue; }Click to reveal answer
beginner
Can multiple elements share the same ID in HTML?
No. IDs must be unique within a page. Only one element should have a particular ID to keep styles and scripts predictable.
Click to reveal answer
intermediate
Which has higher priority: an ID selector or a class selector?An ID selector has higher priority (specificity) than a class selector. This means styles from an ID selector override those from a class selector if both apply.Click to reveal answer
beginner
Example: What will this CSS do?<br>
#main { color: red; }It will make the text color red for the element with
id="main". Only that element is affected.Click to reveal answer
How do you select an element with the ID "footer" in CSS?
✗ Incorrect
The
# symbol is used to select elements by their ID.Can two elements have the same ID in a valid HTML document?
✗ Incorrect
IDs must be unique to ensure styles and scripts target the correct element.
Which selector has higher specificity?
✗ Incorrect
ID selectors (#menu) have higher specificity than class selectors (.menu), element selectors (div), or universal selectors (*).
What symbol is used before the ID name in CSS selectors?
✗ Incorrect
The
# symbol is used to select elements by their ID.If an element has both an ID and a class, which style will override if both set the same property?
✗ Incorrect
ID selectors have higher specificity and override class selectors.
Explain what an ID selector is and how it is used in CSS.
Think about how you pick a unique item in a group.
You got /4 concepts.
Describe the difference in priority between ID selectors and class selectors in CSS.
Which one wins when both apply?
You got /3 concepts.