Select every <i> element inside <p> element where the <p> element is the first child of its parent. - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:first-child

Description

Select every <i> element inside <p> element where the <p> element is the first child of its parent.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
p:first-child i {
    background: yellow;
}
</style><!--  ww w .  j  ava 2s .  c o m-->
</head>
<body>

<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>

<div>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
</div>

</body>
</html>

Related Tutorials