DEV Community

Cover image for CSS can do that?
Ananya Neogi
Ananya Neogi

Posted on • Updated on

CSS can do that?

A list of amazing things that CSS can do!

EDIT: Some of these properties won't work in some browsers because of support. We can check for browser support using @supports and add fallback styles accordingly. Please use Chrome to view the examples 🙂

1. box-decoration-break

This CSS property specifies how an element's fragments should be rendered when broken across multiple lines, columns, or pages.


2. attr()

We can retrieve values of the selected element in CSS by using attr(). This method could be really helpful with accessibility purposes.


3. backface-visibility

This CSS property sets whether the back face of an element is visible when turned towards the user. Thinking of a card flip UI?


4. conic-gradient

Gradients are a wonderful thing. You might've used to style backgrounds with linear gradients but do you know we can use pure css to create pie charts with the help of conic-gradient!

To better understand how conic-gradients, reference the MDN docs on it


5. filter

Who needs photoshop filter effects when you have CSS filters. 🙃
Filter functions applies graphical changes to the appearance of an input image. The effects we can achieve are as follows - blur, brightness, contrast, grayscale, hue-rotate, opacity, invert, sepia, saturate, drop-shadow.

drop-shadow filter is pretty amazing. It lets you apply drop shadow to the input image.


6. mix-blend-mode

This CSS property sets how an element's content should blend with the content of the element's background or its parent.


Amazing things can be achieved by mixing blend modes and filters with images and text. Learn more on MDN Docs.


7. first-letter

One of my favourite things in books and magazines are the beautiful drop-caps. We can create drop with first-letter pseudo-element.


8. shape-outside

This CSS property provides a way to customise wrapping adjacent inline content around complex objects rather than simple rectangular boxes.


Open the example in a different tab and try changing the width of the window and notice how the text wraps around the image.


9. writing-mode

This CSS property sets whether the lines of text are laid out horizontally or vertically. We can have these values-

  • horizontal-tb - Content flows horizontally from left to right, vertically from top to bottom.
  • vertical-lr - Content flows horizontally from left to right, vertically from top to bottom.
  • vertical-rl - Content flows horizontally from right to left, vertically from top to bottom.

Checkout this this example to see it in action.


10. Adding gradient to text

This is achieved with the combination of -webkit-background-clip: text and -webkit-text-fill-color: transparent CSS properties.


11. Smooth scroll snap

scroll-snap-type CSS property sets how snap points are applied on the scroll container.

This example shows vertical(y) scroll with value mandatory. MDN docs does a great job on explaining how to use other values such as proximity and horizontal scroll(x).


These are just a few great things CSS can do. Possibilities are endless! 🥳

Latest comments (120)

Collapse
 
tinkermakar profile image
Makar

I thought I am good at CSS... before reading this

Collapse
 
zippytyro profile image
Shashwat Verma

Dope

Collapse
 
louislow profile image
Louis Low

Very insightful !

Collapse
 
khalil profile image
khalil Chermiti • Edited

awwwww thank you so much for this great post, i just save it so that i can recheck it later <3

Collapse
 
seibas profile image
sebastiano

I am learning, thanks! 👏👏👏

Collapse
 
colotuna profile image
colotuna

very Nice, well job friend

Collapse
 
weakish profile image
Jang Rush

Hi, I'd like translate this amazing tutorial to Chinese. Can you give me the permission? The translated text will be published on nextfe.com. Thanks in advance.

Collapse
 
ananyaneogi profile image
Ananya Neogi

Hey! Sure, you can translate it as long as you link back to the original post :)
Do share the link once it's published.

Collapse
 
weakish profile image
Jang Rush

Just finished the translation: nextfe.com/css-can-do-that/
The original post is back-linked at the beginning of the translated text.

Thread Thread
 
ananyaneogi profile image
Ananya Neogi

Great! :)

Collapse
 
mxrcochxvez profile image
Marco Chavez

I just learned about the text gradient the other day! Thanks for sharing, always fun to learn about CSS and it's expansive capabilities.

Collapse
 
arefriant profile image
Aref Khandan

Wow, actually im going to use "Smooth scroll snap" in my proj right now! thank you

Collapse
 
shmdhussain12 profile image
Mohamed Hussain

Thanks for the article on what css and HTML can simply do without the Js.....

Collapse
 
katieadamsdev profile image
Katie Adams

This was great! Learnt loads of interesting CSS techniques that I'm definitely looking into.

Collapse
 
bdougherty profile image
Brad Dougherty

I had never heard of box-decoration-break, that's really cool!

FWIW, all of the examples work in Safari. Everything but conic gradient and scroll-snap work in Firefox also. The backface-visibility example will work everywhere if the -webkit-prefixed version is added (for Safari) and the non-prefixed version to .flip-card-inner (for Firefox).

Collapse
 
thumbone profile image
Bernd Wechner

Some nice things here but like others I'd prefer to read such lists with only stable well supported features not browser specific stuff, that needs fallbacks. Just my preference as I'm interested in building sites that just work and while I'm happy to expect people to gave basically the latest browser in their context, I am not interested in asking them to use a particular browser (that defies the freedom of the web for me).

Some comments may only be visible to logged-in visitors. Sign in to view all comments.