I have several <p> elements in my HTML body. I want to show only the first two paragraphs and set display:none for all paragraphs after. Why is the following code not working?
<html> <head> <style type="text/css"> p:gt(2) { display:none; } </style> </head> <body> <p>1</p> <p>2</p> <p>3</p> <p>4</p> </body> </html>
My code still shows all 4 paragraph elements in a Chrome web browser.
How do I fix my code to achieve the goal I originally stated?
html css css-selectors
John
source share