I'm trying to select the first h1
inside a div
with a class called detail_container
. It works if h1
is the first element within this div
, but if it comes after this ul
it won't work.
<style type="text/css">
.detail_container h1:first-child
{
color:blue;
}
</style>
</head>
<body>
<div class="detail_container">
<ul>
<li></li>
<li></li>
</ul>
<h1>First H1</h1>
<h1>Second H1</h1>
</div>
</body>
</html>
I was under the impression that the CSS I have will select the first h1
no matter where it is in this div
. How can I make it work?