CSS MCQ Questions And Answers - Selectors
This section focuses on "Selectors" in Cascading Style Sheets (CSS). These Multiple Choice Questions (MCQ) should be practiced to improve the Cascading Style Sheets (CSS) skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. How many different types of selectors in CSS?
A. 3
B. 4
C. 5
D. 6
View Answer
Ans : C
Explanation: There are several different types of selectors in CSS : CSS Element Selector,CSS Id Selector,CSS Class Selector,CSS Universal Selector,CSS Group Selector.
2. ___________ selects the HTML element by name.
A. element selector
B. Class Selector
C. Universal Selector
D. Group Selector
View Answer
Ans : A
Explanation: element selector selects the HTML element by name.
3. An id is not always unique within the page so it is chosen to select a single, unique element.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: An id is always unique within the page so it is chosen to select a single, unique element.
4. Id written with the ?
A. .
B. $
C. @
D. #
View Answer
Ans : D
Explanation: Id is written with the hash character (#), followed by the id of the element.
5. Class name can be started with a number?
A. Yes
B. No
C. Depends on class
D. Depends on element
View Answer
Ans : B
Explanation: A class name should not be started with a number.
6. The universal selector is used as a ?
A. Wildcard Character
B. Page Character
C. Commas character
D. None of the above
View Answer
Ans : A
Explanation: The universal selector is used as a wildcard character. It selects all the elements on the pages.
7. ___________ are used to separate each selector in grouping.
A. #
B. .
C. ,
D. :
View Answer
Ans : C
Explanation: Commas are used to separate each selector in grouping.
8. A similar rule called the ____________ is specified using the plus sign (+) and is used to select elements that would be siblings of each other.
A. class selectors
B. adjacent-sibling selector
C. attribute selectors
D. None of the above
View Answer
Ans : B
Explanation: A similar rule called the adjacent-sibling selector is specified using the plus sign (+) and is used to select elements that would be siblings of each other.
9. Which of the following selectors selects adjacent siblings?
A. E > F
B. E < F
C. E + F
D. E - F
View Answer
Ans : C
Explanation: h1 + p {color: red;}
10. Which of the following selectors selects direct descendents?
A. E > F
B. E < F
C. E + F
D. E - F
View Answer
Ans : A
Explanation: body > p {background-color: yellow;}
Discussion