If you access to MDN, Can I Use, or web.dev t search for a web feature, you may see something like this. So what is it?
According to Google's new definition,
Web Platform Baseline brings clarity to information about browser support for web platform features.
Web Platform Baseline gives you clear information about which web platform features are safe to use in your projects today. When reading an article, or choosing a library for your project, if the features used are all part of Baseline, you can trust the level of browser compatibility. By aligning with Baseline, there should be no surprises when testing your site.
So, in general it's just a piece of information to let you know wether the feature is compatible with what browser.
It has 2 phases:
You can checkout details post and previous definition of Baseline here.
Features that are in Baseline newly available will also show a badge, along with the year that they became available. So, anything that became interoperable across the core browser set last year is part of Baseline 2023.
There are many features, but i don't think i'll ever use all of them, so i'd like to introduce some that might actually be helpful.
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Subgrid
The doc might be a little too detailed, but subgrid is basically that when you declare grid template on the grid-container, then, in the grid-item declare the grid template using subgrid, children elements of grid-item will be placed gridly based on the grid-container.
For example:
Without subgrid, we'll dedclare grid template once on grid-container (black line), and once in grid-item (green line). If we do this, children elements (yellow line) will be placed gridly base on grid-item level. Because of this, the height of those children elements on each card is not align, the longer the content, the bigger height it gets.
With subgrid, children elements of grid-item will be placed gridly based on the grid-container. so it can be aligned.
The code is something like this.
Output:
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_containment/Container_queries
The name says it all, unlike media queries, which mean your elements are responsive to view port, container queries means elements are responsive to their container.
Below is the syntax we can use,
For example: we have a post container and a card inside it. To adjust the text size of the card base on the width of post. Do this:
container-type: size
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/:has
If you have ever used Tailwind, you must be familiar with group
and peer
, which are used to style other elements when parent/same-level element is hover/focus/…
Now you can do similar thing, or even more with has()
Here's the simpliest example, in which i turn the text content to red when title is hovered.
Although this seems almighty, there are some note-taking point below:
More details here!
I have been using SCSS for so long, i didn't realize that css has become a lot more cool now. Although these features are not widely availale, most devices have latest browser version and has no problem using them.
I hope you'll have a different look on CSS now and have fun with it!