Am I doing something wrong or just a bug?


#1


I wrote this and the previev shows the with the color I wanted for "random3" to "random2"
The "random2" gets the color when i change the code to a:nth-child(2) the color from "random2" changes back to blue and nothing else happens
I said next and the program said my code it correct is it just a bug ?

CSS

a:hover{
text-decoration:none    
}

a:first-child{
color:#CDBE70    
}

a:nth-child(3){
color:#FFC125    
}

HTML

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>Result</title>
	</head>
	<body>
	<a href="http://www.gbvsoft.com/">Random1</a>
	<br></br>
	<a href="http://noisebetweenstations.com/personal/weblogs/">Random2</a>
	<br></br>
	<a href="http://www.blasthaus.com/">Random3</a>
	</body>
</html>


#2

the exercise assumes you don't insert breaks (<br></br>), the problem is that nth-child counts all elements. so if you wouldn't have had breaks, the third link would be colored, but now with the breaks, the third child is the second link (first child: first link, second child: break, third child: second link)

That is the cause of the problem


#3

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