HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 57
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. Which CSS selector targets all <p> elements inside a <section> container, but not those inside a <div>?
A section p:not(div p) {}
B section > p:not(div p) {}
C section p:not(div p) {}
D section > p {}
2. Which CSS selector targets all <a> elements on a page, except those inside a navigation menu with the class nav?
A a.nav a {}
B a:not(.nav a) {}
C a:not(.nav) {}
D a:not(.nav a) {}
3. Which CSS selector targets all <div> elements with the class highlight that contain an <img> element with an empty alt attribute?
A .highlight img[alt=""] {}
B .highlight img:empty[alt=""] {}
C .highlight img[alt=""]:not(:empty) {}
D .highlight img[alt=""] {}
4. Which CSS selector targets a <div> element with the class wrapper that contains more than 5 <p> elements?
A div.wrapper:has(p:nth-child(n+5)) {}
B div.wrapper > p:nth-child(n+5) {}
C div.wrapper p:nth-child(n+5) {}
D div.wrapper:has(p) {}
5. Which CSS selector targets all <input> elements of type text that have a placeholder attribute starting with “Enter”?
A input[type="text"][placeholder^="Enter"] {}
B input[type="text"]:placeholder^="Enter" {}
C input[type="text"]:placeholder-start("Enter") {}
D input[type="text"]::placeholder^="Enter" {}
6. Which CSS selector targets all <p> elements on a page except those inside a <section> with the class no-style?
A section.no-style p {}
B p:not(.no-style p) {}
C p:not(section.no-style p) {}
D p:not(section > .no-style) {}
7. Which CSS selector targets all <input> elements of type radio with a name attribute equal to “gender” that are checked?
A input[type="radio"][name="gender"]:checked {}
B input[type="radio"]:checked[name="gender"] {}
C input[name="gender"]:checked {}
D input[type="radio"][name="gender"]:active {}
8. Which CSS selector targets all <span> elements that are directly followed by a <div> element in a section with the class content?
A section.content span + div {}
B section.content > span + div {}
C section.content span + div {}
D section.content span > div {}
9. Which CSS selector targets all <a> elements in a navigation menu (nav) that have not been visited yet?
A nav a:visited {}
B nav a:link {}
C nav a:unvisited {}
D nav a:active {}
10. Which CSS selector targets all <p> elements in a .blog container that are not followed by a <ul> element?
A .blog p:not(+ ul) {}
B .blog p:not(:has(+ ul)) {}
C .blog p:not(:has(ul)) {}
D .blog p + :not(ul) {}