PrepAway - Latest Free Exam Questions & Answers

You develop an HTML5 webpage. You have the following HTML markup:

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. $ (-sectionarticle: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-);

Explanation:

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


Leave a Reply