I'm learning HTML and CSS and I'm confused how nth-of-type
work? On googling i got to know that it select nth element of the type specified.In the below code I want to style all the first paragraph but only above two paragraphs are getting styled.
<!DOCTYPE html>
<html>
<head>
<title>selector</title>
<style type="text/css">
p:nth-of-type(1){
color: blue;
}
</style>
</head>
<body>
<h1>this is heading 1</h1>
<p>this is a paragraph 1</p> //--> this is working
<div>
<h2>this is heading 2</h2>
<h2>this is the heading 3</h2>
<p>this is paragraph 2</p> //-->this is also working
</div>
<h3>this is heading 4
<h4>this is heading 5</h4>
<p>This is paragraph 3</p> //-->Not working
</h3>
</body>
</html>