My google avatar.
devrel@google
notecss

Advanced attr() in Chrome 133. Opening new ways to integrate with CSS from your HTML:

<li scroll-snap="start"></li>
<li scroll-snap="center"></li>
[scroll-snap] {
  scroll-snap-align: attr(scroll-snap type(start | center | end));
}

Try it & learn more from Bramus @ Chrome Developers

8 comments #

440likes

plus aqandrew.com, jordisz.dev, hipstersmoothie.com and 413 more

59reposts
  • Roni Laukkarinen
  • ffoodd
  • Veikko Eeva
  • Jon Henshaw
  • blokche
  • Emanuel Saramago
  • Ryan Mulligan
  • Doug Parker
  • Gustav Hansen
  • That HTML Blog & The Spicy Web
  • Daniel
  • mr lochlan
  • GENKI
  • Jacob Marshall
  • Sangeeth Sudheer
  • SanityPress
  • @joellesenne.dev
  • Zéfling
  • leventef
  • Jack Iakovenko

and 38 others

Join the conversation on

Would scroll-snap-align: attr(scroll-snap type("start | center | end")) be valid? That seems more equivalent to the first example.
Jason ChristaJason Christa

@argyleink This CSS feature is really really cool! Though inventing custom attribute names without `data-` is something we want to avoid generally

JelmerJelmer
yep! you can: `attr(scroll-snap type(start | center | end))`
Adam ArgyleAdam Argyle

@jelmerdemaat indeed, and especially avoid inventing custom attributes that don't have a `-`.

worth mentioning too that the `data-` prefix gets you included in `element.dataset`; very handy

Adam ArgyleAdam Argyle
Is this ???? Tailwind?

@argyleink Uuuu thats a nice one! New attr() features are super powerful, and I am just waiting for new patterns we will explore soon.

https://mastodon.social/@pawelgrzybek/113843980110588700

Paweł Grzybek (@pawelgrzybek@mastodon.social)
Paweł GrzybekPaweł Grzybek
This is awesome!
coding at nightcoding at night