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”).ess ( “background-color”, “#f2f2f2”);
C.
$ (“article:first-of-type”) .css(“background-color”, “#f2f2f2”);
D.
$ (“section:first-of-type”).css(“background-color”, “#f2f2f2”);
http://www.w3schools.com/cssref/sel_first-of-type.asp
answer c
The answer is A.
https://css-tricks.com/almanac/selectors/f/first-child/
No, it is C
http://www.w3schools.com/code/tryit.asp?filename=FATTU6JE8I26
And why is that? Why A doesn’t work? I think it should but it doesn’t. Why?
Oh, I think I know. H1 interrupts this
H1 is the first child.