css selectors mcq online test free
If your CSS Selectors are not strong, you will face difficulties in learning the entire CSS. Therefore, to help you improve your CSS Selectors topic, we have brought this MCQ test. With the help of this test, your CSS Selectors topic will become much better.
Q1. What is the main function of a selector in CSS ?
The main function of a selector in CSS is to select an element and apply style to that element.
Q2. Which of the following symbols does NOT represent a CSS selector?
The '!' symbol is called an Exclamation Mark. It does not represent a CSS selector.
Q3. Which symbol is used to represent an ID selector in CSS?
The ID selector is represented by the # symbol. When we target an element by its ID in CSS, we place # before the ID name.
Q4. a[href='https://google.com']{color: red;} What will be the output of the given code?
All anchor tags that contain the link https://google.com will become red. This is an example of an attribute selector.
Q5. div > p { color: blue } Which selector is used in the given code?
The given code uses a child selector ( > ), which selects direct child elements.
Q6. Which of the following is NOT a CSS selector?
In CSS there are ID selector, Child selector, and Pseudo selector, but there is no selector called harm selector.
Q7. .p1{background:red;} For which option will the given code work?
In the given code the class p1 is targeted, so the correct option is <p class='p1'>this is a pc </p> because it contains the class p1.
Q8. We want to set the background color of all div elements to red. What will be the correct code?
When we want to apply the same background color to all div elements, we use a tag selector.
Q9. Our webpage has five h2 tags. We want to set the background color of four h2 tags to yellow. Which selector is the best for this?
When we want to apply the same style to multiple elements, we use a class selector.
Q10. h1, h2, p { color:red; } Which selector is used in the given CSS code?
In CSS, a group selector is used to select multiple elements at the same time.