CSS Multiple Choice Questions & Answers (MCQs) focuses on “Selectors”.
Q 1. What type of selector is used in this case?
p {line-height: 150%;}
A. element Selectors
B. class Selectors
C. id Selectors
D. none of the mentioned
Show Answer
Answer:-A. element SelectorsExplanation
These selectors are called element selectors and are simply used as follows: element-name { /* properties */ }Q 2. By applying an ___________ a style can be applied to just a single tag.
A. class rule
B. element rule
C. id rule
D. none of the mentioned
Show Answer
Answer:-C. id ruleExplanation
By applying an id rule, a style can be applied to just a single tag. For example, if we name a tag with a unique id attribute as followsQ 3. The _____________ attribute is used to define the name(s) of the class(es) to which a particular tag belongs.
A. id
B. element
C. class
D. none of the mentioned
Show Answer
Answer:-C. classQ 4. What will be the output of below mentioned code snippet?
p strong {background-color: yellow;}
A. Strong have yellow background
B. Both p and strong have yellow background
C. Strong element within a p element have a yellow background
D. None of the mentioned
Show Answer
Answer:-C. Strong element within a p element have a yellow backgroundExplanation
All occurrences of the strong element within a p element have a yellow background.Q 5. 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. attribute selectors
C. adjacent-sibling selector
D. none of the mentioned
Show Answer
Answer:-C. adjacent-sibling selectorQ 6. Which of the following selectors selects any tag with an id attribute set?
A. E#id
B. .class
C. #id
D. *
Show Answer
Answer:-C. #idExplanation
Example:#test {color: green;} /* makes a tag with id=’test’ green */Q 7. Which of the following selectors selects direct descendents?
A. E > F
B. E F
C. E + F
D. E ~ F
Show Answer
Answer:-A. E > FExplanation
Example: body > p {background-color: yellow;} /* makes all p tags that have the body tag as their immediate parent have the background color yellow */Q 8. Which of the following selectors selects siblings?
A. E.class
B. E ~ F
C. *
D. E, F, G
Show Answer
Answer:-B. E ~ FExplanation
Example: p ~ strong {font-style: italic;} /* sets the font style to italic on all strong tags that have a p tag as a preceding sibling */Q 9. Which of the following selectors selects the specified elements of type E with a particular class value?
A. E.class
B. E ~ F
C. *
D. E, F, G
Show Answer
Answer:-A. E.classExplanation
Example: h1.note {text-decoration: underline;} /* underlines all h1 tags with class=’note’ */Q 10. Which of the following selectors selects adjacent siblings?
A. E > F
B. E F
C. E + F
D. E ~ F
Leave a Reply