HTML Element Style How to - Hide second p tag within a div








Question

We would like to know how to hide second p tag within a div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div>p:first-child+p {
  display: none;
}<!--from w  ww. j a v  a2s . c o m-->
</style>
</head>
<body>
  <div>
    <p>One</p>
    <p>Two</p>
    <p>Three</p>
  </div>
</body>
</html>

The code above is rendered as follows: