Help me with CSS selectors, part 18


<!DOCTYPE html>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<p><a href=""> hola1</a></p>
		<p><a href="">hola2 </a></p>
		<p><a href="">hola3</a></p>

In the CSS tab I have:


I understand that the error comes from that the <a> are the children of the <p>,so a:nth-child(3) would make the desired color in the third "a" inside a paragraph. But say that I want to keep the HTML code, with the paragraphs, how do I fix the CSS?


well, the paragraphs are first, second and third element of body so you should simply do:


then select the anchor element inside the paragraph:

p:nth-child(3) a

so we use the paragraphs for the counting


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.