CSS Questions & Answers – Advanced Selectors

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

Q 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

Show Answer Answer:-C. E[attr$=value]
Explanation Example: p[title$=”!”] {color: red;}

Q 2. Which of the following selector selects the elements that are checked?
A. E ~ F
B. ::after
C. :checked
D. none of the mentioned

Show Answer Answer:-C. :checked
Explanation Example: :checked {color: blue;}

Q 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

Show Answer Answer:-A. :default
Explanation Example: :default {background-color: red;}

Q 4. Which of the following selector selects an element that has no children?
A. :no-child
B. :nochild
C. :inheritance
D. :empty

Show Answer Answer:-D. :empty

Q 5. Which of the following selector selects the elements that are currently enabled?
A. :enabled
B. :empty
C. :element
D. none of the mentioned

Show Answer Answer:-A. :enabled
Explanation Example: input:enabled {background-color:white;}

Q 6. Which of the following selector selects the element that is the first child of its parent that is of its type?
A. :last-child
B. :first-of-type
C. ::first-line
D. ::first-letter

Show Answer Answer:-B. :first-of-type
Explanation Example: strong:first-of-type {font-size:bigger;}

Q 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

Show Answer Answer:-C. :not(s)
Explanation Example: *:not(h1) {color: black;}

Q 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

Show Answer Answer:-C. :only-child
Explanation Example: h1:only-child {color: blue;}

Q 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

Show Answer Answer:-A. :target
Explanation Example: :target{color:red;}

Q 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. :invalid
B. :required
C. :optional
D. :valid

Show Answer Answer:-D. :valid
Explanation Example: :valid {color: green;}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page