Skip to content

Commit a397ab7

Browse files
estelledipikabhchrisdavidmills
authored
New CSS reference: Keyframe selectors (mdn#42573)
* New CSS reference: Keyframe selectors * make it plural * example height" * force * force * force * ick * Apply suggestions from code review Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org> Co-authored-by: Chris Mills <chrisdavidmills@gmail.com> * Update files/en-us/web/css/reference/selectors/keyframe/index.md * Update files/en-us/web/css/guides/scroll-driven_animations/index.md Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org> * Update files/en-us/web/css/guides/syntax/error_handling/index.md Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org> * Update files/en-us/web/css/guides/syntax/error_handling/index.md Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org> * Update files/en-us/web/css/reference/selectors/keyframe/index.md * rename slug * Update files/en-us/web/css/reference/selectors/keyframe_selectors/index.md Co-authored-by: Chris Mills <chrisdavidmills@gmail.com> --------- Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org> Co-authored-by: Chris Mills <chrisdavidmills@gmail.com>
1 parent 8300697 commit a397ab7

File tree

11 files changed

+395
-10
lines changed

11 files changed

+395
-10
lines changed

files/en-us/web/api/csskeyframerule/keytext/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ browser-compat: api.CSSKeyframeRule.keyText
88

99
{{APIRef("CSSOM") }}
1010

11-
The **`keyText`** property of the {{domxref("CSSKeyframeRule")}} interface represents the keyframe selector as a comma-separated list of percentage values. The from and to keywords map to 0% and 100%, respectively.
11+
The **`keyText`** property of the {{domxref("CSSKeyframeRule")}} interface represents the [keyframe selector](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors) as a comma-separated list of percentage values. The from and to keywords map to 0% and 100%, respectively.
1212

1313
## Value
1414

files/en-us/web/api/csskeyframesrule/deleterule/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ deleteRule(select)
1919
### Parameters
2020

2121
- `select`
22-
- : A string which contains the keyframe selector of the rule to be deleted, which must be:
22+
- : A string which contains the [keyframe selector](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors) of the rule to be deleted, which must be:
2323
- a comma-separated list of percentage values between 0% and 100%;
2424
- or, the keywords `from` or `to`
2525

files/en-us/web/api/csskeyframesrule/findrule/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ findRule(select)
1919
### Parameters
2020

2121
- `select`
22-
- : A string which contains the keyframe selector of the rule to be found, which must be:
22+
- : A string which contains the [keyframe selector](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors) of the rule to be found, which must be:
2323
- a comma-separated list of percentage values between 0% and 100%;
2424
- or, the keywords `from` or `to`
2525

files/en-us/web/css/guides/animations/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ The CSS animations module level 2 also introduces the `animation-trigger`, `anim
250250
### At-rules and descriptors
251251

252252
- {{cssxref("@keyframes")}}
253+
- [`<keyframe-selector>`](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors)
253254

254255
### Events
255256

files/en-us/web/css/guides/scroll-driven_animations/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ Scroll the element in the inline direction to see its background color change. S
146146

147147
- [CSS animations](/en-US/docs/Web/CSS/Guides/Animations) module
148148
- {{cssxref("animation-timeline")}}
149-
- {{cssxref("@keyframes")}}
149+
- {{cssxref("@keyframes")}} at-rule
150+
- [`<keyframe-selector>`](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors)
150151
- [CSS overflow](/en-US/docs/Web/CSS/Guides/Overflow) module
151152
- {{glossary("Scroll container")}}
152153
- [Scrollport](/en-US/docs/Glossary/Scroll_container#scrollport)

files/en-us/web/css/guides/scroll-driven_animations/timelines/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ The {{cssxref("view-timeline-inset")}} arguments specify insets (if positive) or
320320

321321
Unlike the scroll timeline's `scroll()` function, there is no `<scroller>` argument in the `view()` function, as the view timeline always tracks the subject within its nearest ancestor scroll container.
322322

323-
In this example, as we are using inset values, we can use the `from` and `to` keyframe selectors.
323+
In this example, as we are using inset values, we can use the `from` and `to` [keyframe selectors](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors).
324324

325325
```css live-sample___anon_view_args
326326
@keyframes action {

files/en-us/web/css/guides/selectors/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ The CSS selectors module also introduces the {{CSSXref(":blank")}}, {{CSSXref(":
189189
- Other [pseudo-elements](/en-US/docs/Web/CSS/Reference/Selectors/Pseudo-elements)
190190
- {{CSSxRef("::cue")}}
191191

192+
- [CSS animations](/en-US/docs/Web/CSS/Guides/Animations)
193+
- [`<keyframe-selector>`](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors)
194+
192195
- {{CSSXref("@namespace")}} at-rule
193196

194197
- {{cssxref("important", "!important")}}

files/en-us/web/css/guides/syntax/error_handling/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ After parsing each declaration, style rule, at-rule, and so on, the browser chec
3737

3838
### At-rule errors
3939

40-
The `@` symbol, known in CSS specifications as an `<at-keyword-token>`, indicates the beginning of a CSS {{cssxref("at-rule")}}. Once an at-rule begins with the `@` symbol, nothing is considered invalid from the parser's standpoint. Everything up to the first semi-colon (`;`) or the opening curly brace (`{`) is part of the at-rule's prelude. The content of each at-rule is interpreted according to the grammar rules for that particular at-rule.
40+
The `@` symbol, known in CSS specifications as an `<at-keyword-token>`, indicates the beginning of a CSS [at-rule](/en-US/docs/Web/CSS/Reference/At-rules). Once an at-rule begins with the `@` symbol, nothing is considered invalid from the parser's standpoint. Everything up to the first semi-colon (`;`) or the opening curly brace (`{`) is part of the at-rule's prelude. The content of each at-rule is interpreted according to the grammar rules for that particular at-rule.
4141

4242
Statement at-rules, such as {{cssxref("@import")}} and {{cssxref("@namespace")}} declarations, contain just a prelude. The semicolon ends the at-rule immediately for [statement at-rules](/en-US/docs/Web/CSS/Guides/Syntax/At-rules#statement_at-rules). If the contents of the prelude are invalid according to the grammar for that at-rule, the at-rule is ignored, with the browser continuing to parse CSS after it encounters the next semi-colon. For example, if an `@import` at-rule occurs after any CSS declaration other than `@charset`, `@layer` or other `@import` statements, the `@import` declaration is ignored.
4343

@@ -52,15 +52,15 @@ Different at-rules have different grammar rules, different (or no) descriptors,
5252

5353
For example, the `@font-face` rule requires both a [`font-family`](/en-US/docs/Web/CSS/Reference/At-rules/@font-face/font-family) and [`src`](/en-US/docs/Web/CSS/Reference/At-rules/@font-face/src) descriptor. If either of these is omitted or invalid, the entire `@font-face` rule is invalid. Including an unrelated descriptor, any other valid font descriptor with an invalid value, or a property style declaration within the `@font-face` nested block will not invalidate the font declaration. As long as the font name and font source are included and valid, any invalid CSS within the at-rule is ignored, but the `@font-face` block is still parsed.
5454

55-
While the grammar of the `@keyframes` at-rule is very different from the `@font-face` rule grammar, the type of error still impacts what gets ignored. Important declarations (marked with the {{cssxref("important")}} flag) and properties that can't be animated are ignored in keyframe rules, but they don't impact other styles declared in the same keyframe selector block. Including an invalid keyframe selector (such as a percentage value less than `0%` or greater than `100%`, or a {{cssxref("number")}} omitting the `%`) invalidates the keyframe selector list and therefore the style block is ignored. An invalid keyframe selector only invalidates the invalid selector's style block; it does not invalidate the entire `@keyframes` declaration. Including styles between two keyframe selector blocks, on the other hand, will invalidate the entire `@keyframes` at-rule.
55+
While the grammar of the `@keyframes` at-rule is very different from the `@font-face` rule grammar, the type of error still impacts what gets ignored. Important declarations (marked with the {{cssxref("important")}} flag) and properties that can't be animated are ignored in keyframe rules, but they don't impact other styles declared in the same [keyframe selector](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors) block. Including an invalid keyframe selector (such as a percentage value less than `0%` or greater than `100%`, or a {{cssxref("number")}} omitting the `%`) invalidates the keyframe selector list and therefore the style block is ignored. An invalid keyframe selector only invalidates the invalid selector's style block; it does not invalidate the entire `@keyframes` declaration. Including styles between two keyframe selector blocks, on the other hand, will invalidate the entire `@keyframes` at-rule.
5656

5757
Some at-rules are almost always valid. The {{cssxref("@layer")}} at-rule comes in both regular and nested forms. The `@layer` statement syntax contains just the prelude, ending with a semi-colon. Alternatively, the nested syntax has layer styles nested between curly braces coming after the prelude. Omitting a closing curly brace may be a logic error but is not a syntax error. In the case of a missing closing brace in `@layer`, any styles coming after where the closing brace should have been are parsed as being in the cascade layer defined in the at-rule's prelude. The CSS is valid as there are no syntax errors; nothing is discarded. A syntax error may cause the named or anonymous layer to be empty, but the layer is still created.
5858

5959
### Errors in selector lists
6060

6161
There are many ways you might make a mistake writing a selector, but only invalid selectors cause a selector list to be invalid (See [invalid selector list](/en-US/docs/Web/CSS/Reference/Selectors/Selector_list#invalid_selector_list)).
6262

63-
If you include a {{cssxref("class_selectors", "class")}}, {{cssxref("id_selectors", "id")}}, or {{cssxref("type_selectors", "type")}} selector for a class, id, or element (or custom element) that doesn't exist, it may be a logic error but it's not a syntax error. However, if you have a typo in a pseudo-class or a pseudo-element, it might create an invalid selector, which is an error the parser needs to address.
63+
If you include a [class selector](/en-US/docs/Web/CSS/Reference/Selectors/Class_selectors), an [id_selectors](/en-US/docs/Web/CSS/Reference/Selectors/ID_selectors), or a [type selector](/en-US/docs/Web/CSS/Reference/Selectors/Type_selectors) for a class, id, or element (or custom element) that doesn't exist, it may be a logic error but it's not a syntax error. However, if you have a typo in a pseudo-class or a pseudo-element, it might create an invalid selector, which is an error the parser needs to address.
6464

6565
If a selector list contains any invalid selectors, then the entire style block is ignored. There are exceptions: if the invalid selector is within an {{cssxref(":is")}} or {{cssxref(":where")}} pseudo-class (which accept [forgiving selector lists](/en-US/docs/Web/CSS/Reference/Selectors/Selector_list#forgiving_selector_list)) or if the unknown selector is a [`-webkit-` prefixed pseudo-element](#-webkit-_exception), only the unknown selector is ignored as not matching anything. The selector list is not invalidated.
6666

files/en-us/web/css/reference/at-rules/@keyframes/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The **`@keyframes`** [CSS](/en-US/docs/Web/CSS) [at-rule](/en-US/docs/Web/CSS/Gu
3737

3838
## Description
3939

40-
To use keyframes, create a `@keyframes` rule with a name that is then used by the {{ cssxref("animation-name") }} property to match an animation to its keyframe declaration. Each `@keyframes` rule contains a style list of keyframe selectors, which specify percentages along the animation when the keyframe occurs, and a block containing the styles for that keyframe.
40+
To use keyframes, create a `@keyframes` rule with a name that is then used by the {{ cssxref("animation-name") }} property to match an animation to its keyframe declaration. Each `@keyframes` rule contains a style list of [keyframe selectors](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors), which specify percentages along the animation when the keyframe occurs, and a block containing the styles for that keyframe.
4141

4242
You can list the keyframe percentages in any order; they will be handled in the order they should occur.
4343

files/en-us/web/css/reference/properties/animation-range/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Scroll to see the element being animated.
252252

253253
{{EmbedLiveSample("Examples", "100%", "480px")}}
254254

255-
Note how the `from`, or `0%`, keyframe property values are not applied to the animated element until the top block border edge is `10%` past the container's bottom edge; it is full size, fully opaque, and magenta. At that point, the animation is applied and it is styled with the values defined by the `0%` keyframe selector. When the `animation-range-end` is reached, 25% from the top of the scrollport, it jumps back to its original styling.
255+
Note how the `from`, or `0%`, keyframe property values are not applied to the animated element until the top block border edge is `10%` past the container's bottom edge; it is full size, fully opaque, and magenta. At that point, the animation is applied and it is styled with the values defined by the `0%` [keyframe selector](/en-US/docs/Web/CSS/Reference/Selectors/Keyframe_selectors). When the `animation-range-end` is reached, 25% from the top of the scrollport, it jumps back to its original styling.
256256

257257
Generally, you will want to set `animation-fill-mode: both` when creating [scroll-driven animations](/en-US/docs/Web/CSS/Guides/Scroll-driven_animations). The jump to the default state occurs because we did not set the {{cssxref("animation-fill-mode")}} property on the element, which can be used to apply an animation's styles to an element before and after the animation's execution. We initially omitted the property in this example to better enable visualizing the effects of `animation-range`.
258258

0 commit comments

Comments
 (0)