HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 54
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 an element with a data-id attribute?
A [data-id] {}
B #data-id {}
C .data-id {}
D data-id {}
2. Which CSS selector selects all <div> elements inside an element with the ID container?
A container div {}
B #container div {}
C div #container {}
D .container div {}
3. Which CSS selector targets the first child of a parent element?
A parent:first-child {}
B parent > first-child {}
C parent:first-of-type {}
D parent > :first-child {}
4. Which CSS selector targets all <a> elements that do not have a link (no href attribute)?
A a:empty {}
B a:not([href]) {}
C a:link {}
D a[href=""] {}
5. Which CSS selector is used to target an element that is the last child of its parent?
A parent:last-child {}
B parent > :last-child {}
C parent:last-of-type {}
D parent > :last-of-type {}
6. What is the result of the following selector: input[type="text"]
?
A Select all <input> elements of type text.
B Select all <input> elements of type text.
C Select all <text> elements of type input.
D Select all <input> elements that have a text class.
7. Which CSS selector selects all <p> elements that are direct children of an element with the class content?
A .content > p {}
B .content p {}
C content > p {}
D p > .content {}
8. Which CSS selector targets all <input> elements with a disabled class and a disabled attribute?
A input.disabled:disabled {}
B input[disabled].disabled {}
C .disabled[disabled] {}
D input.disabled[disabled] {}
9. Which selector targets a <p> element only if its text is in uppercase (using text-transform: uppercase
in CSS)?
A p:uppercase {}
B p::uppercase {}
C p:text-transform(uppercase) {}`
D This selector does not exist.
10. Which CSS selector targets all elements with a data-*
attribute that starts with "user-"
?
A [data-user-*] {}
B [data-*^="user-"] {}
C [data-user^="*"] {}
D [data-*^="user"] {}