Recall & Review
beginner
What is an attribute selector in CSS?
An attribute selector lets you select HTML elements based on the presence or value of an attribute. For example, you can style all links with a specific href or all inputs with a certain type.
Click to reveal answer
beginner
How do you select elements with a specific attribute regardless of its value?
Use the syntax
[attribute]. For example, input[required] selects all input elements that have the required attribute, no matter its value.Click to reveal answer
intermediate
What does the selector
a[href^='https'] do?It selects all
<a> elements whose href attribute value starts with https. The ^= means 'starts with'.Click to reveal answer
intermediate
Explain the difference between
[attr$='value'] and [attr*='value'] selectors.[attr$='value'] selects elements whose attribute ends with 'value'. [attr*='value'] selects elements whose attribute contains 'value' anywhere inside.Click to reveal answer
advanced
How can attribute selectors improve accessibility and user experience?
They allow styling elements based on attributes like
aria-* or disabled, helping users understand element states visually. For example, styling disabled buttons differently.Click to reveal answer
Which CSS selector matches all
input elements with a type attribute equal to "checkbox"?✗ Incorrect
The selector
input[type='checkbox'] matches inputs whose type attribute is exactly 'checkbox'.What does the selector
a[href$='.pdf'] select?✗ Incorrect
The
$= attribute selector matches attribute values that end with the given string.Which selector matches elements with an attribute named 'data-info' regardless of its value?
✗ Incorrect
The selector
[data-info] matches elements that have the 'data-info' attribute, no matter what its value is.What does the selector
input[required] do?✗ Incorrect
The selector matches elements that have the 'required' attribute present, regardless of its value.
Which attribute selector matches elements whose attribute contains a specific word?
✗ Incorrect
The
[attr~='word'] selector matches elements whose attribute contains the word 'word' as a separate word, separated by spaces.Describe how you would use CSS attribute selectors to style all links that open in a new tab.
Think about the attribute that controls opening links in new tabs.
You got /3 concepts.
Explain the difference between the attribute selectors [attr^='value'], [attr$='value'], and [attr*='value'].
Focus on where the value appears in the attribute.
You got /3 concepts.