The general sibling combinator element1 ~ element2 selects every sibling that follows the first element. Use it when you need to style all later siblings, not just the immediate next one.
01
~ tilde
Combinator.
02
Siblings
Same parent.
03
All after
Not just next.
04
+ vs ~
One vs many.
05
h2 ~ p
Common pattern.
06
Layout
Dynamic CSS.
Fundamentals
Introduction
The general sibling combinator element1 ~ element2 in CSS selects an element that is a sibling of another specified element. Both elements must share the same parent and the matched element must appear after the first one in the document.
This selector is particularly useful for applying styles to multiple elements that follow a heading, label, or section marker — without adding extra classes to every sibling.
Definition and Usage
Write the first selector, a tilde (~), then the second selector. Every matching element2 that comes after element1 at the same nesting level receives the styles. Other elements may appear between them; unlike +, they do not break the match.
💡
Beginner Tip
If you only need the very next sibling, use + instead. Use ~ when you want all following siblings — for example every paragraph after a section heading.
Foundation
📝 Syntax
The signature of the general sibling selector is:
syntax.css
element1 ~ element2{/* CSS properties */}
This syntax targets element2 when it is preceded by element1 and both elements share the same parent.
.section-title ~ p applies body-text styles to every paragraph after the title. Pairing with :last-of-type removes extra bottom margin on the final paragraph.
📄 Forms & Comparison
Form sibling patterns and + vs ~ differences.
Example 3 — Checkbox and following labels
Style sibling labels that follow a checkbox input in a custom form layout.
When the checkbox and labels are siblings, input ~ label indents all labels that follow the input. Combined with :checked, you can highlight options when the box is selected.
Example 4 — + vs ~ side by side
See how h2 + p matches one paragraph while h2 ~ p matches all of them.
plus-vs-tilde.css
/* Adjacent: only the first paragraph */h2 + p{color:#2563eb;font-weight:600;}/* General: all paragraphs after h2 */h2 ~ p{color:#15803d;font-style:italic;}
With +, only the first paragraph after the heading is blue and bold. With ~, every following paragraph turns green and italic. Choose based on how many siblings you need to style.
Tips
💬 Usage Tips
Style many siblings at once — Use ~ instead of repeating classes on every element.
Combine with pseudo-classes — Patterns like input:checked ~ .panel enable toggle UIs without JavaScript.
Scope with a parent class — Write .article h2 ~ p to limit matches to one section.
Prefer + for spacing — Use .item + .item for gap between consecutive items; use ~ when all following items need the same style.
Read HTML top to bottom — Remember that only siblings after the first selector are matched.
Watch Out
⚠️ Common Pitfalls
Only following siblings — Elements before element1 are never matched by ~.
Must share a parent — Nested descendants are not siblings; the combinator will not match them.
Confusing + and ~ — + stops at the next sibling; ~ continues through all later siblings.
New headings reset context — Paragraphs after a second <h2> match relative to that heading, not the first one.
Over-broad rules — A bare h2 ~ p on a complex page may style more paragraphs than intended; scope when needed.
A11y
♿ Accessibility
Do not hide content with CSS alone — Avoid using sibling selectors to remove important text from view.
Form associations — Prefer <label for="id"> over relying solely on sibling layout for accessibility.
Color contrast — Styled sibling text must still meet WCAG contrast ratios.
Focus order — Sibling-based form layouts should preserve logical tab order in HTML.
Semantic structure — Use proper heading levels so screen readers benefit from your section patterns.
🧠 How ~ Works
1
Find element1
The browser locates all elements matching the first part of the selector, such as h2.
Match
2
Scan later siblings
For each match, the engine checks following siblings under the same parent.
Siblings
3
Apply to all matches
Every sibling matching element2 gets the CSS properties — not just the first one.
Style
=
🔗
Flexible layouts
Multiple siblings share styles based on what precedes them in the HTML.
Compatibility
🖥 Browser Compatibility
The general sibling combinator is supported in all modern browsers and has been available for many years.
✓ Baseline · Universal support
Sibling combinators everywhere
element ~ element works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
~ general sibling combinator99% supported
Bottom line:element ~ element is safe for production layouts in all modern projects.
Wrap Up
🎉 Conclusion
The element1 ~ element2 selector is a versatile tool for targeting sibling elements in your CSS. By understanding how the general sibling combinator works, you can create more flexible and dynamic styles for headings, sections, forms, and stacked components.
Pair it with the adjacent sibling combinator (+) in your mental toolkit: use + for the immediate neighbor and ~ when every following sibling should share the same look.
The general sibling combinator (element1 ~ element2) selects all element2 nodes that follow element1 and share the same parent. Unlike +, it matches every following sibling, not just the immediate next one.
The + adjacent sibling combinator matches only the single next sibling. The ~ general sibling combinator matches all later siblings at the same level, even if other elements appear between them.
Yes. The ~ combinator only works between siblings — elements that share the same parent in the DOM. Nested descendants are not matched.
No. The general sibling combinator only matches siblings that come after element1 in document order. Earlier siblings are ignored.
Yes. All modern browsers support the ~ combinator. It has been part of CSS for many years and is safe for production use.