WEB-DEVELOPMENT-FOUNDATION practice question 4 of 15
What describes the matches resulting from the img: first-child selector?
Full set: 75 questionsThe CSS selector img:first-child is a combination of a type selector (img) and a structural pseudo-class (:first-child). The :first-child pseudo-class targets any element that is the first among a group of sibling elements within a parent container. Therefore, the selector img:first-child specifically matches any element that is the very first child of its parent element. If any other element, like a
or
, comes before the
inside the parent, the
will not be selected.
A. This describes the :hover pseudo-class, which applies when a user's cursor is positioned over an element.
C. This describes the :last-child pseudo-class, which targets the very last element within a parent container.
D. This describes the :only-child pseudo-class, which targets an element that is the sole child of its parent. ---
1. Mozilla Developer Network (MDN) Web Docs: In the documentation for the :first-child pseudo-class, it states, "The :first-child CSS pseudo-class represents the first element among a group of sibling elements." This confirms that the selector targets the initial element.
Source: MDN Web Docs, :first-child, retrieved from https://developer.mozilla.org/en-US/docs/Web/CSS/:first-child
2. W3C (World Wide Web Consortium) Specification: The official CSS Selectors Level 3 specification defines the behavior of this pseudo-class.
Source: W3C, Selectors Level 3, Section 6.6.5.1. :first-child pseudo-class, W3C Recommendation 29 September 2011. It specifies, "The :first-child pseudo-class represents an element that is the first child of some other element."
3. MIT OpenCourseWare: Course materials for web design and development frequently cover fundamental CSS selectors. Lecture notes on CSS structure and selectors explain this concept.
Source: MIT OpenCourseWare, 6.813/6.831 User Interface Design and Implementation, Fall 2011, Lecture 4: CSS, which covers the box model and selectors, including structural pseudo-classes like :first-child. Available at https://ocw.mit.edu/courses/6-813-user-interface-design-and-implementation-fall-2011/
Keep practicing
Take the free WEB-DEVELOPMENT-FOUNDATION practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other WEB-DEVELOPMENT-FOUNDATION practice questions
- Question 2What is one of the possible values of the text-align property?
- Question 3What is matched by the :hover selector?
- Question 5Which two color definitions are valid for use with CSS? Choose 2 answers.
- Question 8What does the timelines tool of Safari Web Inspector enable a developer to do?
- Question 9Developers consider three platforms for viewport sizes. What is one of them?
- Question 10Which CSS unit is a relative unit?
