Edu
Hub
Courses
AI Tools
Leaderboard
Login/Register
AR
Abdullah Rashid
abdullah@example.com
Navigation
📚
Courses
🏆
Leaderboard
✨
AI Tools
←
CSS Selectors Quiz - Medium Level
⏱
15:00
Quit
0 / 20 answered
0%
CSS Selectors Quiz - Medium Level
10 questions · Medium difficulty · 00:20:00 min
🔥 In Progress
Question 1
Which selector selects elements that have a specified attribute, regardless of its value?
[attr]
[attr^=value]
[attr~=value]
[attr=value]
Question 2
What does the selector a[href$='.pdf'] target?
Links whose href attribute starts with '.pdf'
Links whose href attribute equals exactly '.pdf'
Links whose href attribute contains '.pdf' anywhere
Links whose href attribute ends with '.pdf'
Question 3
Which selector matches elements whose attribute value contains a whole word separated by spaces?
[attr$=value]
[attr*=value]
[attr|=value]
[attr~=value]
Question 4
What is the difference between [attr|=value] and [attr^=value]?
There is no difference, they behave identically
[attr^=value] matches whole words only, while [attr|=value] matches substrings
[attr|=value] matches 'value' or 'value-' prefix, while [attr^=value] matches any string starting with 'value'
[attr|=value] matches values at the end, while [attr^=value] matches values at the beginning
Question 5
Which selector selects all <p> elements that are direct children of a <div>?
div + p
div p
div ~ p
div > p
Question 6
What does the general sibling combinator (~) select?
All siblings that come after the first element, sharing the same parent
Only the first child of the parent
All siblings both before and after the element
Only the immediately next sibling
Question 7
Which selector targets the paragraph immediately following a heading (h2)?
h2 ~ p
h2 + p
h2 > p
h2 p
Question 8
What does :nth-child(2n+1) select?
Every odd-numbered child
Every third child starting from the second
Every even-numbered child
The first child only
Question 9
Which pseudo-class matches an element only if it is the last of its type among its siblings?
:nth-last-of-type(1)
:last-child
:last-of-type
:only-of-type
Question 10
How does :nth-of-type() differ from :nth-child()?
They are identical in behavior
:nth-of-type() only works with tables
:nth-child() counts only same-type elements, while :nth-of-type() counts all siblings
:nth-of-type() counts only elements of the same type, while :nth-child() counts all siblings
Question 11
Which pseudo-class selects form input elements that are required but currently empty and valid?
:required:invalid
:required:valid
:optional:empty
:mandatory:valid
Question 12
What does :not(div.intro) select?
All div elements that do not have the class 'intro'
Only elements without any class
All div elements with class 'intro'
All elements that are NOT div elements with class 'intro'
Question 13
Which pseudo-class matches the checkbox state where the checkbox is selected?
:active
:focus
:checked
:selected
Question 14
What is the correct order of the three parts of the :first-line pseudo-element styling rule?
p:first-line:: { color: red; }
p::first-line { color: red; }
p:line-first { color: red; }
::first-line p { color: red; }
Question 15
Which statement about ::before and ::after is TRUE?
They require the 'content' property to render anything visible
They replace the element's actual content
They only work on empty elements
They work without the 'content' property
Question 16
What does ::selection style?
The first selected child element
The portion of a document highlighted by the user
Elements with the 'selected' attribute
The selected option in a dropdown list
Question 17
Which of the following selector combinations has the HIGHEST specificity?
#header .nav ul li a:hover
#header #nav a.active
div#header nav ul li a.active
body #header .nav a
Question 18
What is the specificity of the selector ul li.item:nth-child(2)?
0-0-4 (4 elements)
0-1-3 (1 class, 3 elements)
0-2-2 (2 classes including pseudo-class, 2 elements)
0-3-1 (3 classes, 1 element)
Question 19
Which selector targets the element being dragged OR a text selection made by the user during a drag operation?
::selection:active
::selection
:drag
:active
Question 20
Which selector correctly targets all anchor elements that are unvisited links AND have the class 'external'?
a.external:visited
a:link.external
a.link:external
a:external:link
✅ Answered:
0
⬜ Unanswered:
8
📊
20%
done
Submit Answers →