Skip to content

Commit f04ee88

Browse files
committed
Add section on hiding view transition names and clarify rendering behavior
1 parent 8f66ce9 commit f04ee88

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

src/content/docs/basics/pseudos.mdx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,37 @@ There are two exceptions:
168168

169169
- The API ignores the `view-transition-name` of a fragmented element, i.e. an element that consists of two or more boxes, like an inline element that spans two lines. View transition names assigned to such elements are ignored.
170170

171-
- The API also ignores the `view-transition-name` of an element if that element is not rendered, like the `<head>`, or if it is skipped. For instance, you can use the same `view-transition-name` multiple times within the same DOM, provided that all but one instance have their `display` CSS property set to `none`. This can also be done by setting an HTML element's hidden attribute or property. Looking for an example? This technique is utilized in the intra-document [image morph examples](/basics/examples/#image-morph-examples) on this site. This trick also works with an ancestor with `content-visibility: hidden` but not with a simple `visibility: hidden` directly on the element.
171+
- The API also ignores the `view-transition-name` of an element if that element is not rendered or skipped.
172172

173+
### Hiding View Transition Names
174+
There are several ways to prevent the rendering of an element and thus to hide its view transition name.
175+
176+
You can hide elements by adding the `hidden` attribute.
177+
|HTML attribute|effect|
178+
|-|-|
179+
|`hidden`|hides view transition names of subtree|
180+
181+
Or you can use CSS properties to hide view transition names:
182+
183+
|CSS property|value|Hides view transition names&hellip;|
184+
|-|-|-|
185+
|`display`|`none`| &hellip;of the subtree|
186+
|`display`|`contents`|&hellip;of the element, only|
187+
|`content-visibility`|`hidden`|&hellip;of the subtree|
188+
|`view-transition-scope`|`all`|&hellip;of the subtree|
189+
|`visibility`|`hidden`|<span style="color: red;">&hellip;none</span>|
190+
191+
Here `view-transition-scope` is a new CSS property that is currently only supported in Chrome. With value `all` it hides the view transition names of its subtree but does not change the rendering of the elements.
192+
193+
With these mechanisms to hide view transition names, you can use the same `view-transition-name` multiple times within the same DOM, provided that all but one instance are hidden.
194+
195+
Looking for an example? This technique is utilized in the intra-document [image morph examples](/demo/BasicS/) on this site, where one element has `display: none` and the other has `display: block`.
196+
197+
This trick also works with `content-visibility: hidden` but not with a simple `visibility: hidden` directly on the element.
198+
199+
200+
201+
### Special Names
173202
The static user agent stylesheet provides one default name for the document, called `root`.
174203

175204
```css title="static user agent stylesheet"

0 commit comments

Comments
 (0)