Log in
Sign up for FREE
arrow_back
Library
4.4 Understanding CSS Selectors and IDs Quiz
By KATIE LEE
star
star
star
star
star
Share
share
Last updated over 1 year ago
5 questions
Add this activity
1
1
1
1
1
Question 1
1.
Why is selecting by ID considered more specific than selecting by class or tag in CSS?
A) ID can only be used once per page, while classes can be reused.
B) ID applies to all elements on a webpage, while classes apply to only one.
C) ID selectors are easier to write than class or tag selectors.
D) ID selectors are automatically applied to all HTML elements.
Question 2
2.
If an HTML element has both a class and an ID assigned to it, which style will take precedence if there is a conflict?
A) The style from the class will always take precedence.
B) The style from the tag will take precedence.
C) The style from the ID will take precedence.
D) The styles will combine and create a new style.
Question 3
3.
What is a valid way to name an ID in CSS?
A) 1stElement
B) my element
C) my-element
D) my_element
Question 4
4.
Consider the following CSS rules:
`p { color: green; }`
`.alert { color: red; }`
`#logo { color: blue; }`
If an element has the class "alert" and the ID "logo," what color will the text be?
A) Green
B) Red
C) Blue
D) It will display a mix of all three colors.
Question 5
5.
Which of the following statements about CSS ID selectors is true?
A) An ID can be reused on multiple elements within the same page.
B) An ID must always start with a number.
C) An ID can only be applied to one specific element on a webpage.
D) An ID selector is less specific than a class selector.