You develop an HTML5 webpage. You have the following HTML markup: You need to add a background color to the first article in each section. Which code segment should you add to the webpage?
A.
$ ("section article:first-child").css("background-color", "#f2f2f2");
B.
$ ("section:first-child").css ( "background-color", "#f2f2f2");
C.
$ ("article:first-of-type") .css("background-color", "#f2f2f2");
D.
$ ("section:first-of-type").css("background-color", "#f2f2f2");
Suggested Answer:C🗳️
The :first-of-type selector matches every element that is the first child, of a particular type, of its parent. Reference: CSS3 :first-of-type Selector
I have tested and this DOES NOT work
$("section article:first-child").css("background-color", "red");
But this works perfectly.
$("article:first-of-type").css("background-color", "red");
C is the right answer.
This section is not available anymore. Please use the main Exam Page.70-480 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
BadBot
5 years, 1 month agonelaed
4 years, 10 months agonelaed
4 years, 10 months ago