NEW
Font size
WorksheetsUnderstanding CSS Selectors and Specificity
Total questions: 11
Worksheet time: 11mins
What is a CSS rule composed of?
A selector and a property
A selector and a declaration block
A property and a value
A declaration block and a value
Which of the following is an example of an ID selector in CSS?
.site-title
#site-title
site-title
site-title#
How do you select elements with a specific class in CSS?
Using the hash (#) symbol
Using the dot (.) symbol
Using the colon (:) symbol
Using the asterisk (*) symbol
What does a pseudo-class selector allow you to do?
Apply styles to an element based on its ID
Apply styles to an element based on its class
Apply styles to an element based on its state
Apply styles to an element based on its tag
Which of the following is an example of a pseudo-class selector?
a:hover
#hover
.hover
hover
In the context of CSS, what is meant by "specificity"?
The order in which CSS rules are written
The importance of a CSS rule
The precision of a CSS selector in targeting elements
The number of properties in a CSS rule
How would you select an `` element that is a descendant of a `
section em#bio
section#bio em
#bio section em
em section#bio
Which of the following statements is true about CSS inheritance?
All CSS properties are inherited by default
Only properties related to text are inherited by default
Inheritance is determined by the specificity of the selector
Inheritance is determined by the order of the CSS rules
What is the purpose of using descendant selectors in CSS?
To apply styles to elements based on their ID
To apply styles to elements based on their class
To apply styles to elements that are nested within other elements
To apply styles to elements based on their tag
Given the following CSS code, what will be the background color of the <div> element?
```div { background-color: red; } div:hover { background-color: blue; } ```
Red
Blue
Red when hovered, Blue otherwise
Blue when hovered, Red otherwise
Which of the following is a pseudo-class in CSS?
:hover
.hover
#hover
hover
