CSS Questions & Answers – Advanced Selectors

This set of CSS Multiple Choice Questions & Answers focuses on “Advanced Selectors”.

1. Which of the following selector selects all elements of E that have the attribute attr that end with the given value?
a) E[attr^=value]
b) E[attr$=value]
c) E[attr*=value]
d) none of the mentioned
View Answer

Answer: b
Explanation:

Example: p[title$="!"] {color: red;}

2. Which of the following selector selects the elements that are checked?
a) E ~ F
b) ::after
c) :checked
d) none of the mentioned
View Answer

Answer: c
Explanation:

advertisement
advertisement
Example: :checked {color: blue;}

3. Which of the following selector selects the elements that are the default among a set of similar elements?
a) :default
b) :%
c) :disabled
d) none of the mentioned
View Answer

Answer: a
Explanation:

Example: :default {background-color: red;}

4. Which of the following selector selects an element that has no children?
a) :empty
b) :nochild
c) :inheritance
d) :no-child
View Answer

Answer: a
Explanation: None.
advertisement

5. Which of the following selector selects the elements that are currently enabled?
a) :element
b) :empty
c) :enabled
d) none of the mentioned
View Answer

Answer: c
Explanation:

Example: input:enabled {background-color:white;}

6. Which of the following selector selects the element that is the first child of its parent that is of its type?
a) :first-of-type
b) :last-child
c) ::first-line
d) ::first-letter
View Answer

Answer: a
Explanation:

advertisement
Example: strong:first-of-type {font-size:bigger;}

7. Which of the following selector selects elements that do not match the selector s?
a) :!(s)
b) :nth-child(s)
c) :not(s)
d) none of the mentioned
View Answer

Answer: c
Explanation:

Example: *:not(h1) {color: black;}

8. Which of the following selector selects an element if it’s the only child of its parent?
a) :root
b) :nth-oftype(n)
c) :only-child
d) none of the mentioned
View Answer

Answer: c
Explanation:

Example: h1:only-child {color: blue;}

9. Which of the following selector selects the element that is the target of a referring URI?
a) :target
b) :selection
c) ::selection
d) :URI
View Answer

Answer: a
Explanation:

Example: :target{color:red;}

10. Which of the following selector applies styles to elements that are valid per HTML5 validations set either with the pattern or type
attributes?
a) :valid
b) :required
c) :optional
d) :invalid
View Answer

Answer: a
Explanation:

Example: :valid {color: green;}

Sanfoundry Global Education & Learning Series – CSS.

To practice all areas of CSS, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.