New CSS Features You Might Not Know About

shubhracodes

Shubhra Agarwal

Posted on August 5, 2021

New CSS Features You Might Not Know About

☑ Scroll snapping

It gives you the option to lock the user’s viewport to a certain parts or element of your site. It is very useful to create cool transitions and help users focus on the most important page elements while scrolling down the page.
image

You can find a simple demo of it here.This effect is visible in mobile apps a lot, yet, with scroll snapping, you can bring it to websites as well.
https://codepen.io/tutsplus/pen/qpJYaK

Usage is also relatively simple on the most basic level. You simply apply the type of scroll snapping to a container and define where its children should snap to.

Of course, there is more to it. If you want to learn about it, CSS Tricks have great write up.
https://css-tricks.com/practical-css-scroll-snapping/

That only leaves a look at browser compatibility, which is pretty good.
image

☑ :is and :where

They allow you to reduce repetition in CSS markup by shortening lists of CSS selectors.

For example, compare this:
image

To this:
image

The same thing works with :where :
image

If the markup is the same, what’s the difference?
The difference is that :is is a lot more specific. It takes the level of specificity of the most specific element in the parentheses.

In contrast to that, the specificity of :where is always zero. Consequently, it is a lot easier to override further down the line.

  • Would love to hear your take on this. Do share your views.
  • A lot more interesting CSS properties are on the way.
💖 💪 🙅 🚩
shubhracodes
Shubhra Agarwal

Posted on August 5, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related