I'm trying to figure out how to make this CSS example work the way I want it to.
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.col p:first-child {
background:yellow;
}
</style>
</head>
<body>
<div class="col">
<h1>Woot</h1>
<p>I am a super nun. I am a super nun.</p>
<p>I am a super nun. I am a super nun.</p>
</div>
</body>
</html>
Basically, I need to style the first <p>
of an element in a specific way, but the first-child
selector doesn't work if it's not actually the first child. Is there a way in CSS to select the first child of a specific type?