5 CSS Tricks & Tips That You Should Know 🚀 + Giveaway 
Tags: css, webdev, html, beginners
Published: 2021-04-20 00:35:14

CSS plays a major part in the field of web development and can be easy and at a point, it can also be advanced and tough, throughout CSS's history, numerous tricks have been discovered by the developer community. Today I will tell you a few of them.

So let's get started!

## Reset
This one is pretty simple, it basically means to reset the whole document's default styling which is given by the browser itself. Most developers make a reset when they want nothing to get in their project's way or maybe for some specific project that needs one! Every developer has their own preference for using which reset as I use:

```css
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
```

Some developers use:
```css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
```
The above reset is [meyerweb.com](https://meyerweb.com/) and for more, you can just search reset CSS on google to find your own preference.

## Capitalization
This is a common trick but it is sometimes not taught in the CSS tutorials or course, so many developers still don't know this trick. It basically capitalizes the first letter of every word in a particular tag. Look at this for example:

{% codepen https://codepen.io/codewithgarvit/pen/KKaBWKK %}

As you can see I have not capitalized any letter manually in the HTML, instead, I wrote `text-transform: capitalize;` and it did it dynamically.

## Centering
Centering is easy but, in my case, I usually don't remember the code to center text or content. So I use some short code snippets for that which I stored in my notes 😅.

You can use `text-align: center;` to **center the text**

To **vertically center text in a `div`**, you can use `margin: auto;`, but to give you a proper example you should take a look at this:

{% codepen https://codepen.io/codewithgarvit/pen/KKaxgBd %}

and then you can also add `text-align: center to center it both, horizontally and vertically.

To center an **image**, you should first of all turn it into a `block` element and do a `margin: auto`.

## Drop Caps
Remember that 1st big letter in every chapter of your literature book or the start of a novel or a book. You can do that by using this snippet:

![snippet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8n29r8t47opdfrvhvrc.png)


## Prevent Highlighting
If you don't want the user to select or highlight anything on your website to prevent copying content, or maybe for some personal or any reasons, you can just use this:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pmq36d9sb561ft2seq1.png)

---

## ⚡️ Giveaway ⚡️
We are giving away any course you need on Udemy. Any price any course.
Steps to enter the giveaway
--> React to this post
--> Subscribe to our [Newsletter](https://worldindev.ck.page/) <-- Very important
--> Follow me on [Twitter](https://twitter.com/garvitmotwani) <-- x2 Chances of winning

The winner will be announced on May 1, Via Twitter

---

Thank you very much for reading this article.

Comment any tricks & tips you know!

**PLEASE LIKE, SHARE, AND COMMENT**

Follow me on [Dev](https://dev.to/garvitmotwani) and [Twitter](https://twitter.com/GarvitMotwani)

---

Read also:
{% link https://dev.to/worldindev/6-python-tips-tricks-that-no-one-teaches-4j73 %}

{% link https://dev.to/worldindev/8-javascript-tips-tricks-that-no-one-teaches-24g1 %}

Subscribe to our [newsletter](https://chipper-motivator-3112.ck.page/05710ea3d3) to receive our weekly recap directly on your email!

Join us on [Discord](https://discord.gg/aWS2YKk6) to participate in hackathons with us / participate in our giveaways!

Happy Coding.