Subsequent-sibling Combinator (~)

W3C CSS Snapshot 2026

Choose matching elements that appear later under the same parent. Other elements can sit in between.

On this page

Syntax and values

Value or syntaxWhat it does
h2 ~ pMatches every later p that shares the h2 element’s parent.

Try the example

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Subsequent-sibling Combinator (~)</title>
  <style>
h2 ~ p { color: teal; }
  </style>
</head>
<body>
<section>
  <h2>Workshop</h2>
  <p>Registration opens Monday.</p>
  <hr>
  <p>Bring a notebook.</p>
</section>
<p>Outside the section.</p>
</body>
</html>

What to expect Both paragraphs in the section turn teal. The paragraph outside the section has a different parent.

Official references