HTML CSS examples for CSS Selector:first-child
Select every <i> element inside <p> element where the <p> element is the first child of its parent.
<!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>