HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 45
Multiple choice questions and answers (MCQs) on HTML/CSS to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as tags, web standards, CSS selector, objects, and more. This quiz will easily prepare anyone to pass their online test.
1. If you want to apply a style only to the first paragraph that directly follows a div, which CSS selector would you use?
A div + p
B div ~ p
C div > p
D div p
2. If you want to target only the <p> elements that are direct children of a <div>, which CSS selector would you use?
A div + p
B div ~ p
C div > p
D div p
3. What is the effect of the * selector in CSS?
A It selects all elements on the page
B It selects all elements inside a <div> element
C It selects all elements with a class
D It selects all elements with an ID
4. Which CSS selector targets all <a> elements that have an href attribute starting with “https”?
A a[href^="https"]
B a[href$="https"]
C a[href*="https"]
D a[href="https"]
5. Which CSS selector is used to select all odd-numbered list items?
A li:nth-child(odd)
B li:nth-child(even)
C li:nth-of-type(odd)
D li:nth-of-type(even)
6. Which tag is used to define a horizontal line to separate sections?
A <break>
B <line>
C <hr>
D <divider>
7. Which HTML tag is used to highlight a portion of text?
A <highlight>
B <mark>
C <strong>
D <em>
8. Which CSS selector targets an element only when it has focus?
A :active
B :focus
C :hover
D :visited
9. Which CSS selector is used to group multiple selectors and apply the same style to them?
A selector1, selector2
B selector1 selector2
C selector1 > selector2
D selector1 ~ selector2
10. Which CSS selector is used to add content before an element’s content?
A ::after
B ::before
C ::first-letter
D ::first-line