Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> p { margin: 0; } article:first-of-type { background-color: #777777; color: #ffffff; } </style> </head> <body> <h2>:first-of-type selector example</h2> <article> <p>This is a first element!</p> <p>This <em>nested 'em' is first</em>!</p> <p>This <strong>nested 'strong' is first</strong>, but this <strong>nested 'strong' is last</strong>!</p> <p>This <span>nested 'span' gets styled</span>!</p> <q>This is a 'q' element!</q> <p>This is a last element.</p> </article> </body> </html>