<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html> <head>
<title>How to Write a Good Report</title>
<style type="text/css">
div.weather strong:first-child {color:red;}
</style>
</head>
<body>
<div class="weather">
It's <strong>very</strong> hot and <strong>incredibly</strong> humid.
</div>
</body> </html>
Why only “very” is in color red while “incredibly” not since both of them are first child of the element specified by “div.weather strong”?
first-childmeans “an element that is the first child”, not “the first child of this element.”So your example means “the
strongthat is the first child ofdiv.weather“.If you want to make, say, the first word in all the
<strong>s within the div come out red, you’ll need to add some markup and do something like this: