6 useful CSS features you might not know about
Tags: css, webdev, ui, frontend
Published: 2024-04-27 17:20:25

**CSS is getting bigger and bigger and even though we work daily with this style language, we do not know all the features we can use to better help us in our daily development. But in this article I will show you some CSS properties that can make a difference in your code. 😁**

Some time ago I created an article called [6 Powerful CSS Techniques You Can Use Instead of Javascript](https://dev.to/dionarodrigues/6-powerful-css-techniques-you-can-use-instead-of-javascript-2f44) and now I decided to extend this list by adding 6 other good CSS features that I believe can be useful and that most of us may not know about them.

## ::marker

I won't judge you if you still use `list-style-type` or `::before` to change the marker of a list element, don't worry. 😁 However, I would like to introduce you to the CSS pseudo-element called `::marker`. This feature was released a few years ago and is supported in all modern browsers and provides everything we need to customize not only the bullet content, but also the color, white space and all animations, transitions and font properties.

```css
li::marker {
  content: '♪ ';
  font-size: 1.2em;
  color: purple;
}
```

Keep in mind that this pseudo-element has greater specificity than `list-style-type`. Read more about the [CSS ::marker pseudo-element in the MDN documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/::marker).

## currentcolor

What if you want the border color of an element to be the same as the text color? Assuming you have a `<div>` whose border and the text inside it are blue, how would you manage it? I bet you probably thought about setting the same color twice, once for the property called “text” and once for the “border-color”, right? Forget it because now you can use the `currentcolor` keyword as it refers to the value of the “color” property.

```css
div {
  color: blue;
  border: 10px solid currentcolor; /* border-color will be blue */
}
```

Read more about this old [currentcolor keyword in w3schools](https://www.w3schools.com/colors/colors_currentcolor.asp).

## color-mix()

For me, this is one of the coolest fully supported CSS features introduced in 2022 but started working in all modern browsers last year. I can't imagine how powerful this can be when we need to create a color palette by mixing two different colours - something that was only possible to do automatically using a JavaScript-based solution.

```css
.result {
  background-color: color-mix(in srgb, blue, red);
}
```

![CSS color-mix function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hc9jronqcwzrhgoag2km.jpg)

The first parameter of this `color-mix()` function is a bit strange but it refers to the [interpolation method](https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-method).

Read more about color-mix() in this fantastic [article by Smashing Magazine](https://www.smashingmagazine.com/2022/06/simplify-color-palette-css-color-mix/). And also in this another [article on by MDN](https://developer.mozilla.org/en-US/blog/color-palettes-css-color-mix/). And [play around with this Codepen example](https://codepen.io/smashingmag/pen/jOZvVqM).

## mix-blend-mode

Have you ever played around with blending modes in some graphics software, like Photoshop, to merge colours and patterns between background and foreground to create cool images? Now CSS also provides a way to do this effect by using the property `mix-blend-mode`. Among many effects, you can use “multiply”, for example, which results in the multiplication of the top and bottom colours.

```css
.img {
  mix-blend-mode: multiply;
}
```

![CSS mix-blend-mode property](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o7eb5b35vye2smh6uiht.jpg)

Read more about [mix-blend-mode and all possible effects in the MDN documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter).

## backdrop-filter

Released about 7 years after CSS Filters, the CSS `backdrop-filter` property allows us to apply graphic effects to the area behind the element. Just like the previous CSS property, it can be very useful when you want to make the interface more visually appealing.

> Because it applies to everything behind the element, to see the effect the element or its background needs to be transparent or partially transparent. - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter)

```css
.title {
  background-color: rgb(255 255 255 / 30%);
  backdrop-filter: grayscale(75%);
}
```

![CSS backdrop-filter property](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21ei2p2wwlkyi0jqlpi8.jpg)

Read more about [backdrop-filter and all possible effects in the MDN documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode).

## accent-color

Last but not least, if you, like me, worked with CSS before 2022, you know how difficult it was to change the colours of checkbox and radio inputs, right? Although we still have a limitation to manage this type of HTML controls, we now have a CSS property called `accent-color` to easily manage their colours in some state.

```css
input[type='checkbox'] {
  accent-color: purple;
}
```

The above styles can be seen when a checkbox is checked. Read more about [accent-color in the MDN documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color).

## Conclusion

CSS has been greatly improved and many new features appear every year and some that we don't know about have been around for a long time. The secret is not to try to memorize them all, but once you know them it becomes easier to understand what you can do using just CSS, which can greatly improve performance - in addition to the fact that it can be much easier to maintain the code.

I hope you learned something here and that this article has inspired you to continue searching for CSS features.

See you next time! 😁