RSS FeedTwitterMastodonBlueskyShare IconHeart IconGithub IconArrow IconClock IconGUI Challenges IconHome IconNote IconBlog IconCSS IconJS IconHTML IconShows IconOpen Source Software IconSpeaking IconTools IconShuffle IconNext IconPrevious IconCalendar IconCalendar Edit IconNotebook IconObservable Notebooks Icon
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

Join the conversation on

55 likes
16 reposts
  • 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
#CSS advanced attr() Unlocking new ways to integrate with CSS from your HTML nerdy.dev/advanced-attr
Adam ArgyleAdam Argyle
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

Crawl the CSS Webring