9 Useful CSS Tricks that You Should Know

Discover new things about CSS, you’ll be fascinated by it, and everything will be more interesting.

Amisiy
Muzli - Design Inspiration

--

The CSS universe is full of tricks that we don’t know, so can’t say that I listed all the tricks of CSS in this part of the story, the more you know about it, the more you discover, and everything will be more interesting.

1) Text Selection Color

When you visit a website or read a blog, you often select the text with the mouse, it’s just the blue color selection with white text. you can make your website stand out with a customized text selection.

Text Selection Color With background(#616161) and text color(#e6e6e6) that is different with body background(#e0e0e0)
Text Selection Color

Use the selection pseudo-element to give the text selection on your websites a personal touch.

Text Selection Color — Selection pseudo-element
Text Selection Color — CSS Syntax

2) Drop Caps

To get a professional article/newspaper look, it’s good to use a drop cap for the first letter of your text. The drop cap is that large capital letter and the text is wrapped around it.

Drop Caps Example — amisiy
Drop Caps Example

Use the first-letter pseudo-element to decorate your first letter, no need to use span with .dropcap class name.

Text Selection Color — first letter pseudo-element
Drop Caps — CSS Syntax

3) Smooth Scrolling

you visit some websites and try to go to different sections, it scrolls smoothly to that section. It’s not high-level coding, but with just one line in your CSS, you can achieve this.

Smooth Scrolling Example

You can use the CSS scroll-behavior property with html as a selector to enable smooth scrolling throughout the HTML page.

Smooth Scrolling — CSS scroll-behavior property with html as a selector
Smooth Scrolling — CSS Syntax

4) Input Caret Color

you can change the color of the input field-caret to make it more customized.

Custom Input Caret Color Example As a CSS trick — Amisiy
Custom Input Caret Color Example

You only need to use the caret-color property for this item!

Input Caret Color — CSS Syntax — Amisiy
Input Caret Color — CSS Syntax

5) Drop Shadow

give a much better shadow effect to the transparent images with Drop shadow, This is how your work will look great.

Drop Shadow Example
Drop Shadow Example

This is how you should do it.

Drop Shadow — CSS Syntax — Amisiy
Drop Shadow — CSS Syntax

6) Place-Items

Centering your div element can be daunting sometimes, You can center any div with just a couple of lines of CSS.

Center The Div With Place Items — amisiy
Center The Div With Place Items

Don’t Forget To set display:grid;for the parent element, then use place-items property.

Center The Div With Place Items — CSS Syntax
Center The Div With Place Items — CSS Syntax

7) Custom Scrollbar

The default scrollbar is not attractive to the user, what you can do is customize this scrollbar.

Custom Scrollbar Example

We only do this with CSS, if you want to get full support on the cross browsers, it is better to use JavaScript libraries for scrollbars.

Custom Scrollbar Css Syntax For Webkit
CSS Way For Custom Scrollbar

8) Disable User Selection

Sometimes the user shouldn’t be able to select something on the web page, if used correctly it can give meaning to that element.

Disable User Selection Example — Amisiy
Disable User Selection Example

It’s that easy!

Disable User Selection CSS Syntax — Amisiy
Disable User Selection CSS Syntax

9) Vertical Text

You may visit some websites and see vertical text from the bottom to the top.

Vertical Text Example
Vertical Text Example

With these two CSS properties, you get what you want!

Vertical Text CSS Syntax — Amisiy
Vertical Text CSS Syntax — Amisiy

Conclusion

This is just a small part of CSS tips that may have made you curious and encourage you to learn more and get involved with CSS syntax. we use various libraries in many of our daily tasks. I’m not saying that’s bad, but if you are more familiar with CSS tips, sometimes you can change your ways and take the better one.

--

--

Web Developer | NULLA team • Want to share the things that inspired me in web design and development with you