Skip to content

Commit

Permalink
fix(css): rename 'General sibling' combinator to 'Subsequent-sibling'…
Browse files Browse the repository at this point in the history
… combinator (#29394)
  • Loading branch information
OnkarRuikar authored Oct 2, 2023
1 parent 60265a8 commit 30c8486
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 54 deletions.
5 changes: 3 additions & 2 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@
/en-US/docs/CSS/Flexbox-redirect-3 /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox
/en-US/docs/CSS/Flexible_boxes /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox
/en-US/docs/CSS/Flexible_boxes-redirect-1 /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox
/en-US/docs/CSS/General_sibling_selectors /en-US/docs/Web/CSS/General_sibling_combinator
/en-US/docs/CSS/General_sibling_selectors /en-US/docs/Web/CSS/Subsequent-sibling_combinator
/en-US/docs/CSS/Getting_Started /en-US/docs/Learn/CSS/First_steps
/en-US/docs/CSS/Getting_Started/Boxes /en-US/docs/Learn/CSS/Building_blocks
/en-US/docs/CSS/Getting_Started/Cascading_and_inheritance /en-US/docs/Learn/CSS/Building_blocks/Cascade_and_inheritance
Expand Down Expand Up @@ -11439,7 +11439,8 @@
/en-US/docs/Web/CSS/Filter_Effects/Using_filter_effects /en-US/docs/Web/CSS/CSS_filter_effects/Using_filter_effects
/en-US/docs/Web/CSS/Filters_Effects /en-US/docs/Web/CSS/CSS_filter_effects
/en-US/docs/Web/CSS/Flexbox /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox
/en-US/docs/Web/CSS/General_sibling_selectors /en-US/docs/Web/CSS/General_sibling_combinator
/en-US/docs/Web/CSS/General_sibling_combinator /en-US/docs/Web/CSS/Subsequent-sibling_combinator
/en-US/docs/Web/CSS/General_sibling_selectors /en-US/docs/Web/CSS/Subsequent-sibling_combinator
/en-US/docs/Web/CSS/Grouping_selectors /en-US/docs/Web/CSS/Selector_list
/en-US/docs/Web/CSS/Interactive /en-US/docs/Web/CSS/@media
/en-US/docs/Web/CSS/Layout_cookbook/Recipe:_Media_Objects /en-US/docs/Web/CSS/Layout_cookbook/Media_objects
Expand Down
50 changes: 25 additions & 25 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -78955,31 +78955,6 @@
"Wjjohnst"
]
},
"Web/CSS/General_sibling_combinator": {
"modified": "2020-10-15T21:04:16.746Z",
"contributors": [
"nko6",
"wbamberg",
"mfuji09",
"ExE-Boss",
"fscholz",
"mfluehr",
"Sheppy",
"erikadoyle",
"mikelew42",
"cvrebert",
"MusikAnimal",
"Sebastianz",
"DanSorahan",
"SphinxKnight",
"FredB",
"teoli",
"ethertank",
"tiffon",
"dhar",
"miken32"
]
},
"Web/CSS/ID_selectors": {
"modified": "2020-12-14T11:20:33.993Z",
"contributors": [
Expand Down Expand Up @@ -79475,6 +79450,31 @@
"jwalker"
]
},
"Web/CSS/Subsequent-sibling_combinator": {
"modified": "2020-10-15T21:04:16.746Z",
"contributors": [
"nko6",
"wbamberg",
"mfuji09",
"ExE-Boss",
"fscholz",
"mfluehr",
"Sheppy",
"erikadoyle",
"mikelew42",
"cvrebert",
"MusikAnimal",
"Sebastianz",
"DanSorahan",
"SphinxKnight",
"FredB",
"teoli",
"ethertank",
"tiffon",
"dhar",
"miken32"
]
},
"Web/CSS/Syntax": {
"modified": "2020-07-07T12:39:09.357Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/glossary/css_selector/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The resulting page content is styled like this:
- Combinators

- [Adjacent sibling selectors](/en-US/docs/Web/CSS/Adjacent_sibling_combinator) `A + B`
- [General sibling selectors](/en-US/docs/Web/CSS/General_sibling_combinator) `A ~ B`
- [Subsequent-sibling selectors](/en-US/docs/Web/CSS/Subsequent-sibling_combinator) `A ~ B`
- [Child selectors](/en-US/docs/Web/CSS/Child_combinator) `A > B`
- [Descendant selectors](/en-US/docs/Web/CSS/Descendant_combinator) `A B`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ If you insert some other element such as a `<h2>` in between the `<h1>` and the

{{EmbedGHLiveSample("css-examples/learn/selectors/adjacent.html", '100%', 800)}}

## General sibling combinator
## Subsequent-sibling combinator

If you want to select siblings of an element even if they are not directly adjacent, then you can use the general sibling combinator (`~`). To select all `<img>` elements that come _anywhere_ after `<p>` elements, we'd do this:
If you want to select siblings of an element even if they are not directly adjacent, then you can use the subsequent-sibling combinator (`~`). To select all `<img>` elements that come _anywhere_ after `<p>` elements, we'd do this:

```css
p ~ img
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/learn/forms/ui_pseudo-classes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ input:default ~ span::after {
}
```

This provides a little "Default" label on the item that was originally selected when the page loaded. Note here we are using the general sibling combinator (`~`) rather than the adjacent sibling combinator (`+`) — we need to do this because the `<span>` does not come right after the `<input>` in the source order.
This provides a little "Default" label on the item that was originally selected when the page loaded. Note here we are using the subsequent-sibling combinator (`~`) rather than the adjacent sibling combinator (`+`) — we need to do this because the `<span>` does not come right after the `<input>` in the source order.

See the live result below:

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/_colon_invalid/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ input:required:invalid {

### Showing sections in stages

In this example we use `:invalid` along with `~`, the [general sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator), to make a form appear in stages, so the form initially shows the first item to complete, and when the user completes each item the form displays the next one. When the whole form is complete the user can submit it.
In this example we use `:invalid` along with `~`, the [subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator), to make a form appear in stages, so the form initially shows the first item to complete, and when the user completes each item the form displays the next one. When the whole form is complete the user can submit it.

#### HTML

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/_colon_nth-last-child/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tr:nth-last-child(2) {

### Quantity query

A _quantity query_ styles elements depending on how many of them there are. In this example, list items turn red when there are at least three of them in a given list. This is accomplished by combining the capabilities of the `nth-last-child` pseudo-class and the [general sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator).
A _quantity query_ styles elements depending on how many of them there are. In this example, list items turn red when there are at least three of them in a given list. This is accomplished by combining the capabilities of the `nth-last-child` pseudo-class and the [subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator).

#### HTML

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/adjacent_sibling_combinator/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ li:first-of-type + li {

## See also

- [General sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator)
- [Subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator)
2 changes: 1 addition & 1 deletion files/en-us/web/css/css_selectors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Selectors, whether used in CSS or JavaScript, enable targeting HTML elements bas
- `+` ([Adjacent or next sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator))
- `>` ([Child combinator](/en-US/docs/Web/CSS/Child_combinator))
- `||` ([Column combinator](/en-US/docs/Web/CSS/Column_combinator)) {{Experimental_Inline}}
- `~` ([General or subsequent sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator))
- `~` ([Subsequent sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator))
- " " ([Descendant combinator](/en-US/docs/Web/CSS/Descendant_combinator))
- `|` ([Namespace separator](/en-US/docs/Web/CSS/Namespace_separator))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ The [descendant combinator](/en-US/docs/Web/CSS/Descendant_combinator), denoted

The [child combinator](/en-US/docs/Web/CSS/Child_combinator) is more specific than the descendant combinator. Denoted with the greater than character (`>`), the child combinator selects nodes that are direct children of the first element. Comparing with our previous example, `div > span` will match only the {{HTMLElement("span")}} elements that are direct children of a {{HTMLElement("div")}} element.

### General sibling combinator
### Subsequent-sibling combinator

In addition to descendant selectors, CSS also enables selecting elements based on their siblings. The [general sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator), denoted with a tilde (`~`), selects siblings. Given `A ~ B`, all elements matching `B` will be selected if they are preceded by `A`, provided both `A` and `B` share the same parent. For example, `h2 ~ p` will match all {{HTMLElement("p")}} elements that follow an {{HTMLElement("Heading_Elements", "h2")}}, immediately or not.
In addition to descendant selectors, CSS also enables selecting elements based on their siblings. The [subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator), denoted with a tilde (`~`), selects siblings. Given `A ~ B`, all elements matching `B` will be selected if they are preceded by `A`, provided both `A` and `B` share the same parent. For example, `h2 ~ p` will match all {{HTMLElement("p")}} elements that follow an {{HTMLElement("Heading_Elements", "h2")}}, immediately or not.

### Adjacent sibling combinator

The [adjacent sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator), denoted by the plus symbol (`+`), is similar to the general sibling. However, given `A + B`, it only matches `B` if `B` is immediately preceded by `A`, with both sharing the same parent. Amending our previous example, `h2 + p` will match only the single `<p>` element that _immediately_ follows an `<h2>` element.
The [adjacent sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator), denoted by the plus symbol (`+`), is similar to the subsequent-sibling. However, given `A + B`, it only matches `B` if `B` is immediately preceded by `A`, with both sharing the same parent. Amending our previous example, `h2 + p` will match only the single `<p>` element that _immediately_ follows an `<h2>` element.

### Column combinator

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Combinators are selectors that establish a relationship between two or more simp

- [Adjacent sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator) `A + B`
- : Specifies that the elements selected by both `A` and `B` have the same parent and that the element selected by `B` immediately follows the element selected by `A` horizontally.
- [General sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator) `A ~ B`
- [Subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator) `A ~ B`
- : Specifies that the elements selected by both `A` and `B` share the same parent and that the element selected by `A` comes before—but not necessarily immediately before—the element selected by `B`.
- [Child combinator](/en-US/docs/Web/CSS/Child_combinator) `A > B`
- : Specifies that the element selected by `B` is the direct child of the element selected by `A`.
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/specificity/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The selector weight categories are listed here in the order of decreasing specif
- No value
- : The universal selector ({{CSSxRef("Universal_selectors", "*")}}) and the pseudo-class {{CSSxRef(":where", ":where()")}} and its parameters aren't counted when calculating the weight so their value is 0-0-0, but they do match elements. These selectors do not impact the specificity weight value.

Combinators, such as {{CSSxRef("Adjacent_sibling_combinator", "+")}}, {{CSSxRef("Child_combinator", "&gt;")}}, {{CSSxRef("General_sibling_combinator", "~")}}, [" "](/en-US/docs/Web/CSS/Descendant_combinator), and {{CSSxRef("Column_combinator", "||")}}, may make a selector more specific in what is selected but they don't add any value to the specificity weight.
Combinators, such as {{CSSxRef("Adjacent_sibling_combinator", "+")}}, {{CSSxRef("Child_combinator", "&gt;")}}, {{CSSxRef("Subsequent-sibling_combinator", "~")}}, [" "](/en-US/docs/Web/CSS/Descendant_combinator), and {{CSSxRef("Column_combinator", "||")}}, may make a selector more specific in what is selected but they don't add any value to the specificity weight.

The `&` nesting combinator doesn't add specificity weight, but nested rules do. In terms of specificity, and functionality, nesting is very similar to the {{CSSxRef(":is", ":is()")}} pseudo-class.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
title: General sibling combinator
slug: Web/CSS/General_sibling_combinator
title: Subsequent-sibling combinator
slug: Web/CSS/Subsequent-sibling_combinator
page-type: css-combinator
browser-compat: css.selectors.general_sibling
browser-compat: css.selectors.subsequent-sibling
---

{{CSSRef("Selectors")}}

The **general sibling combinator** (`~`) separates two selectors and matches _all instances_ of the second element that follow the first element (not necessarily immediately) and share the same parent element.
The **subsequent-sibling combinator** (`~`) separates two selectors and matches _all instances_ of the second element that follow the first element (not necessarily immediately) and share the same parent element.

In the following example, the general sibling combinator (`~`) helps to select and style paragraphs that are both siblings of an image and appear after any image.
In the following example, the subsequent-sibling combinator (`~`) helps to select and style paragraphs that are both siblings of an image and appear after any image.

```css
img ~ p {
Expand Down Expand Up @@ -61,7 +61,7 @@ p ~ span {

### Using the combinator with complex selectors

This example contains two [complex selectors](/en-US/docs/Web/CSS/CSS_selectors/Selector_structure#complex_selector), both using the general sibling combinator: `.foo p ~ span` and `.foo p ~ .foo span`.
This example contains two [complex selectors](/en-US/docs/Web/CSS/CSS_selectors/Selector_structure#complex_selector), both using the subsequent-sibling combinator: `.foo p ~ span` and `.foo p ~ .foo span`.

- The first complex selector, `.foo p ~ span`, matches all spans that come after a paragraph _if_ the span and paragraph share the same parent **and** that parent or an ancestor of that parent has the class `.foo`.
- The second complex selector, `.foo p ~ .foo span`, matches all spans that are a descendant of the element with class `.foo` _if_ that element is a sibling of the previously mentioned paragraph.
Expand Down
16 changes: 8 additions & 8 deletions files/en-us/web/xpath/comparison_with_css_selectors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ page-type: guide

This article seeks to document the difference between CSS Selectors and XPath for web developers to be able to better choose the right tool for the right job.

| [XPath feature](/en-US/docs/Web/XPath) | [CSS equivalent](/en-US/docs/Web/CSS/CSS_selectors) |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`ancestor`](/en-US/docs/Web/XPath/Axes#ancestor), [`parent`](/en-US/docs/Web/XPath/Axes#parent) or [`preceding-sibling`](/en-US/docs/Web/XPath/Axes#preceding-sibling) axis | {{CSSxRef(":has",":has()")}} selector {{experimental_inline}} |
| [`attribute`](/en-US/docs/Web/XPath/Axes#attribute) axis | [Attribute selectors](/en-US/docs/Web/CSS/Attribute_selectors) |
| [`child`](/en-US/docs/Web/XPath/Axes#child) axis | [Child combinator](/en-US/docs/Web/CSS/Child_combinator) |
| [`descendant`](/en-US/docs/Web/XPath/Axes#descendant) axis | [Descendant combinator](/en-US/docs/Web/CSS/Descendant_combinator) |
| [`following-sibling`](/en-US/docs/Web/XPath/Axes#following-sibling) axis | [General sibling combinator](/en-US/docs/Web/CSS/General_sibling_combinator) or [adjacent sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator) |
| [`self`](/en-US/docs/Web/XPath/Axes#self) axis | {{CSSxRef(":scope")}} or {{CSSxRef(":host")}} selector |
| [XPath feature](/en-US/docs/Web/XPath) | [CSS equivalent](/en-US/docs/Web/CSS/CSS_selectors) |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`ancestor`](/en-US/docs/Web/XPath/Axes#ancestor), [`parent`](/en-US/docs/Web/XPath/Axes#parent) or [`preceding-sibling`](/en-US/docs/Web/XPath/Axes#preceding-sibling) axis | {{CSSxRef(":has",":has()")}} selector {{experimental_inline}} |
| [`attribute`](/en-US/docs/Web/XPath/Axes#attribute) axis | [Attribute selectors](/en-US/docs/Web/CSS/Attribute_selectors) |
| [`child`](/en-US/docs/Web/XPath/Axes#child) axis | [Child combinator](/en-US/docs/Web/CSS/Child_combinator) |
| [`descendant`](/en-US/docs/Web/XPath/Axes#descendant) axis | [Descendant combinator](/en-US/docs/Web/CSS/Descendant_combinator) |
| [`following-sibling`](/en-US/docs/Web/XPath/Axes#following-sibling) axis | [Subsequent-sibling combinator](/en-US/docs/Web/CSS/Subsequent-sibling_combinator) or [adjacent sibling combinator](/en-US/docs/Web/CSS/Adjacent_sibling_combinator) |
| [`self`](/en-US/docs/Web/XPath/Axes#self) axis | {{CSSxRef(":scope")}} or {{CSSxRef(":host")}} selector |

0 comments on commit 30c8486

Please sign in to comment.