CSS Tips and Tricks #01
Tags: watercooler, css, beginners, webdev
Published: 2021-01-26 11:22:11



For the last couple of months, we at Skynox Tech's Twitter account, sharing a series of tweets known as #CSStricks. We have shared a lot of tricks that otherwise one could not find in online tutorials. Today we decided to compile all those tips and tricks under one hood so that you can find all those in a single place. These tweets will not only improve your CSS game but also helps you save a ton of codes line and help your own touch to your projects.

So here are the tips and tricks of CSS:-

### **1. Smooth Scrolling**

When you visit some websites and try to go to different sections, it scrolls smoothly to that section. It is not some top tier coding, but just one line in your CSS can help you achieve it.

{% twitter 1326822054302261248 %}

### **2. Truncate text using pure CSS**

Sometimes the text is not consistent in cards and makes them look chaotic. Use this trick to limit the text on cards using just CSS.

{% twitter 1326404316953972736 %}

### **3. Input Caret Color**

Want to give a little personal touch to your site. Use this css trick to change the color of the input field-caret to give it a custom color of your liking.

{% twitter 1333727633482391552 %}

### **4. Drop Shadow and Box Shadow**

Do you know that you can use "Drop shadow" for the transparent images?
It will give a much better shadow effect. 

{% twitter 1336581473302941696 %}

### **5. Drop Cap Letter**

You might have seen some blogs with the first letter being huge and the text is wrapped around it. That can be achieved with this simple trick on your text block.

{% twitter 1339873196288454657 %}

### **6. Center that Div**

Centering your div element can be daunting sometimes, but not when you have this trick in your toolbox. You can center any div with just a couple of lines of CSS.

{% twitter 1341675772147363841 %}

### **7. No value, No problem**

Display links when the <a> element has no text value but the href attribute has a link. Pretty neat, right?

{% twitter 1346033700623024128 %}

### **8. Inherit box sizing**

Let "box-sizing" be inherited from HTML. This makes it easier to change "box-sizing in plugins" or other components that leverage other behavior. 

{% twitter 1346411262582910977 %}

## Bonus tips:-

### ** Bonus 1: Better User Experience **

With the modern web technologies enhancements, one of the key focus points is user experience. Even if your website has the best designs but poor user experience, you will not be able to retain them. This is a cool user experience trick to mute videos on autoplay and let the user decide if they want to hear it.

![autoplay](https://dev-to-uploads.s3.amazonaws.com/i/jk4kqy3xl1ow31sau19g.png)

### ** Bonus 2: Selection pseudo class **

Most of the time when you visit any site and try to copy some text, it is just the blue color selection with white text. Use selection pseudo-class to give a personal touch to text selection on your websites. This will give them a personal touch and make your site stand out! 

![selection](https://dev-to-uploads.s3.amazonaws.com/i/ekanu56b52mlzxmdw8wb.png)

That's it, folks!
These are the all tricks I have to share for now. If you want to see more such content and tips and tricks of other web technologies like react, ES6, etc., do follow us on Twitter at [@XenoxDev](https://twitter.com/XenoxDev). We share a lot of cool content and resources to learn web development so make sure to give a follow. 

Until then 👋👋