9 Most Powerful CSS One-Liners

most powerful CSS on-liners
August 15, 2025 | Read time: 3 minutes

Stop Wasting Money On Unused Software Subscriptions

With Software Subscriptions, you can get reminders, see which card is used for what, manage your team, and more.

Use coupon code MARKO for 50% off with Software Subscriptions

Sponsor this newsletter to reach 9,000+ active developers

Make your projects more visually appealing with these easy-to-implement, CSS one-liners.

Let’s get started!

1. Drop shadow

When you work with transparent images, you can use the drop-shadow() filter function to create a shadow on the image’s content, instead of the box-shadow property, which creates a rectangular shadow behind an element’s entire box:

                            
filter: drop-shadow(2px 4px 8px #000);                            
                        

Here you can see the difference:

Drop Shadow

2. Smooth scroll

Smooth scrolling with zero JavaScript and just one line of CSS.

                            
html {
  scroll-behavior: smooth;
}                            
                        

3. Gap

Use the gap CSS property to set the gaps (gutters) between rows and columns.

CSS Gap

4. CSS Scroll Snap

You can use the CSS Scroll Snap feature to create well-controlled scrolling experiences:

5. Inset

Use the inset CSS property as a shorthand for top, right, bottom, left:

Inset

6. Custom cursors

Did you know that you can use your own image, or even an emoji, as a cursor?

                            
.my-cursor {
  cursor: url('path-to-image.png'), auto;
}                            
                        

7. Truncate text

You can use the -webkit-line-clamp property to truncate text to a specific number of lines.

Super useful.

Truncate text

8. Resize

Did you know that you can make any element resizable, just like a <textarea>?

                            
.resize {
  resize: both;
}                            
                        

9. background-clip

Use the `background-clip` property to create beautiful headlines.

background-clip

Quick Recap!

  1. Drop shadow
  2. Smooth scroll
  3. Gap
  4. CSS Scroll Snap
  5. Inset
  6. Custom cursors
  7. Truncate text
  8. Resize
  9. background-clip

 

Which CSS one-liner did you like the most? Let me know!