3 Modern CSS Features in 2 Minutes
Gabe Romualdo

Gabe Romualdo @gaberomualdo

About: See many of my blog posts here on DEV.

Joined:
Aug 11, 2018

3 Modern CSS Features in 2 Minutes

Publish Date: Jan 3 '20
178 6

Title assumes ~275 WPM reading, as used on DEV.to

1. Clip Paths

Clip paths allow you to "clip" elements into a shape, represented in CSS with the polygon, circle, or ellipse functions. For example:

CSS Clip Path Example

div {
    background-image: url(background.jpg);
    clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%);
}
Enter fullscreen mode Exit fullscreen mode

Clip paths are written with the clip-path property for clipping element content, or the background-clip property for clipping element backgrounds.

The CSS polygon function is one of the most common for clipping, and is composed of a list of points (vertices). Each point is written as x y.

For example: 0 0 would signify the top left, whereas 100% 100% would signify the bottom right. The example above uses a point on the bottom right that is not fully at the bottom (only 85%), producing a diagonal effect.

Clip paths are especially popular in flat design for creating slanted areas as shown in the example. I use this on my personal website to draw attention to background images in certain pages.

Basic clip-path usage is supported in all major browsers except Edge and IE: see CanIUse Data for Clip Paths.

You can create your own clip-paths yourself, or you can use a tool like Clippy to automatically generate clip path CSS for you.

2. Blend Modes

Blend modes allow you to blend an element's content with its parent element(s) or its background using specific methods.

Let's say you were trying to overlay a yellow color over a background image. Ordinarily:

CSS Blend Mode Example 1

div {
    background-image: linear-gradient(yellow, yellow)), url(background.jpg);
}
Enter fullscreen mode Exit fullscreen mode

In this case, the yellow color and the image were simply added together to create final result. However, if we wanted to blend the yellow into the image instead of adding it, we could use a blend mode called screen:

CSS Blend Mode Example 2

div {
    background-image: linear-gradient(yellow, yellow)), url(background.jpg);
    background-blend-mode: screen;
}
Enter fullscreen mode Exit fullscreen mode

Blend modes are specified in backgrounds with the background-blend-mode property, and in elements (for blending with backgrounds or parents) with the mix-blend-mode property.

Possible blend modes include: screen, multiply, hard-light, difference, and more. More information on possible blend modes and their effects can be found here on the MDN web docs.

Blend modes are supported in all major browsers except Edge and IE: see CanIUse Data for Background Blend Modes.

3. CSS Filters

CSS filters provide a vast array of options for filtering elements visually. For example:

CSS Filters Example

img {
    filter: blur(10px);
}
Enter fullscreen mode Exit fullscreen mode

Other filters include: sepia, invert, grayscale, and more.

CSS filters have a vast variety of uses, for example: CSS filters have become popular in creating a dark mode effect on sites using the invert filter.

The filter property is supported in all major browsers except IE: see CanIUse Data for CSS Filters.

Thanks for reading!

I hope you enjoyed this post, and found some of the CSS features mentioned to be useful.

Thanks for scrolling.

— Gabriel Romualdo, January 3, 2020

Comments 6 total

  • Shannon Crabill
    Shannon CrabillJan 4, 2020

    😍

    Features like these remind me why I love CSS.

  • Habdul Hazeez
    Habdul HazeezJan 4, 2020

    Great write up.

    Quick tip:

    You wrote: — Fred Adams, January 3, 2019

    I think you meant: — Fred Adams, January 3, 2020

    • Gabe Romualdo
      Gabe RomualdoJan 4, 2020

      Thanks for spotting that! Just a clumsy mistake, sorry. It's fixed now, and thanks again.

      — Gabriel

  • Yaovi
    YaoviJan 4, 2020

    Thanks for sharing this, especially the blend mode.

  • Andrea Gonzales
    Andrea GonzalesJan 5, 2020

    Thanks for these! I especially found clip path useful :)

Add comment