Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ keywords:
css combinator,
css general sibling combinator,
]
hide_table_of_contents: true
---

In CSS, the general sibling selector is used to select an element that is preceded by another element. The general sibling selector is represented by the `~` character between two selectors.

<AdsComponent />
<br />

## Syntax

Expand Down Expand Up @@ -58,6 +60,7 @@ In the HTML code below, the CSS rule will apply the `font-weight: bold` property
:::

<AdsComponent />
<br />

## Example: Using General Sibling Selector

Expand Down Expand Up @@ -109,7 +112,8 @@ Now, you can see the output of the above code in the Browser Window like this:
In the above example, the CSS rule will apply the `font-weight: bold` property to the text inside the `<p>` elements that are preceded by an `<h2>` element.

<AdsComponent />
<br />

## Summary

The general sibling selector (`~`) is used to select an element that is preceded by another element. It is less specific than the adjacent sibling selector (`+`) and more specific than the descendant combinator (` `). The general sibling selector is useful for styling elements that are not directly related but share the same parent.
The general sibling selector (`~`) is used to select an element that is preceded by another element. It is less specific than the adjacent sibling selector (`+`) and more specific than the descendant combinator (` `). The general sibling selector is useful for styling elements that are not directly related but share the same parent.