惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hacker News - Newest:
Hacker News - Newest: "LLM"
Webroot Blog
Webroot Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
N
News and Events Feed by Topic
H
Hacker News: Front Page
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
SecWiki News
SecWiki News
N
News | PayPal Newsroom
T
Tor Project blog
W
WeLiveSecurity
A
Arctic Wolf
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
月光博客
月光博客
AWS News Blog
AWS News Blog
D
Docker
C
CERT Recently Published Vulnerability Notes
MyScale Blog
MyScale Blog
Google Online Security Blog
Google Online Security Blog
大猫的无限游戏
大猫的无限游戏
T
The Blog of Author Tim Ferriss
I
InfoQ
人人都是产品经理
人人都是产品经理
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
Recorded Future
Recorded Future
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
The Exploit Database - CXSecurity.com
D
DataBreaches.Net
S
Security Affairs
WordPress大学
WordPress大学
T
Threatpost
Microsoft Security Blog
Microsoft Security Blog
V
Vulnerabilities – Threatpost
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
B
Blog RSS Feed
Project Zero
Project Zero
P
Proofpoint News Feed

Bram.us

What’s new in Web UI (Google I/O 2026) Cranking View Transtions up to 11 (2026.05.07 @ All Day Hey!) Cranking View Transtions up to 11 (2026.04.28 @ Beyond Tellerrand) Do Websites Need to Function Exactly the Same on Every Platform? Introducing view-transitions-toolkit, a collection of utility functions to more easily work with View Transitions. CSS position: sticky now sticks to the nearest scroller on a per axis basis! Cranking View Transtions up to 11 (2026.03.25 @ devs.gent) More Easy Light-Dark Mode Switching: light-dark() is about to support images! Detect at-rule support in CSS with @supports at-rule(@keyword)
View Transitions: Use the new attr() or match-element for the view-transition-name?
Published by Bramus! · 2026-06-20 · via Bram.us

Skip to content

~

view-transition-name: attr(…);

To recap, the technique Kevin showed is this:

<style>
  .card {
    view-transition-name: attr(data-id type(<custom-ident>), none);
    view-transition-class: card;
  }
</style>

It reads the data-id attribute’s value and casts it to a <custom-ident> for use as the view-transition-name value.

You can see Kevin apply it live here. When applied, all cards will get a view-transition-name and get snapshotted — and therefore also move — individually as part of the View Transition.

Kevin live coding it at CSS Day. Note he starts off typing data() which is later corrected to attr() with some help from Jake and myself.

~

view-transition-name: match-element;

The thing Cyd mentioned is match-element, which automatically gives an element a view-transition-name value based on the element’s identity. In Kevin’s demo this would totally work, and the demo would work just as with the attr() code.

<style>
  .card {
    view-transition-name: match-element;
    view-transition-class: card;
  }
</style>

So, what’s the fuss about then?

~

match-element works … until it doesn’t

The thing with match-element is that it uses element identity to assign automagic values. This element identity is not to be confused with the id attribute — they are two different things.

Think of this identity as an internal number that the browser assigns to created elements. Every time an element is created, the internal counter increments. So if you were to destroy an element and then recreate it including its id, you’d end up with an element that that has a different identity, even though it has the same id.

The side-effect of match-element using element identity, is that are two scenarios when you should not be using match-element at all:

  1. When you build an MPA (aka: a website), match-element doesn’t work at all because nodes in different documents are never the same; they all have a different identity, so match-element can never match them.
  2. If you need to style a specific element from the whole set, then you need the unique name to use in your ::view-transition-*() selectors, which match-element doesn’t give you.

So, there you have it 🙂

~

TL;DR match-element is limited to Same-Document View Transitions and can’t be used to uniquely target any of the View Transition pseudos.

~

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)