5 Hidden CSS Properties You Didn't Know Existed
Tags: css, frontend
Published: 2024-04-22 03:23:38

Cascading Style Sheets (CSS) are the backbone of web design, allowing developers to style and format web pages with ease. While most developers are familiar with the common CSS properties like color, font-size, and margin, there are numerous lesser-known properties that can add functionality to your designs. In this article, uncover five CSS properties that you may not have known existed, but which can significantly enhance your web development projects.

_1. Text-decoration_
```
.menu__list-link:hover {
  text-decoration: underline 2px solid green;
}
```

![text-decoration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi8lujehj83ovqkzbfpc.png)
Turn out for the classic text-decoration: underline you can add 3 more parameters. First is the width of the line (2px), second is the type of line (solid, dotted) and the third is the color for this line (green). 

_2. Text-underline-offset_

```
.menu__list-link:hover {
  text-decoration: underline 2px solid green;
  text-underline-offset: 6px;
}
```
![Text-underline-offset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3hfbsk3mlk6d0be8s3kx.png)

![Text-underline-offset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjes52klh127k3ita0yj.png)
It is very handy. Solve problem that occur pretty often, when some letters go below the line height and during hover effect underline interrupts by those letters. Pretty good solution to create offset from text to underline (6px). 

_3. Inset_

For positioning relative, absolute, and others we often write top, right, bottom, left:
```
  top: 5px;
  right: 3px;
  bottom: 1px;
  left: 4px;
```
to speed up the process of writing we can write above in a shorter version with the property inset:

```
inset: 5px, 3px, 1px, 4px;
```

_4. Object-position_

We often apply to the image object-fit: cover - it will crop the image to a specified height & width in order to look sharp:

![object-fit: cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d7g2h4z68qbgw57158j5.png)

But we can't control which part of the image it will crop. So it is where object position comes into play. 

```
.test {
  height: 350px;
  width: 500px;
  object-fit: cover;
  object-position: bottom;
}
```

![object-position: bottom](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjkwnz4w4mtgd9hd653q.png)
```
object-position: top;
```

![object-position: top](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jy5061gj1cfsqkldatku.png)

As well as we can add: left or right. Or even can be more precise when we specify 2 parameters like object-position: center bottom;

_5. Scroll margin top_

By default, when we link to section on the page `<a href="#fairy-tale__inner">Itinery</a>` it will bring exactly to the top of that section.


![Scroll margin top](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0gbscn4v5jkhsgkzaqy.png)

But if we want to make space we need to use scrool-margin-top

```
#fairy-tale__inner {
  scroll-margin-top: 100px;
}
```

![Scroll margin top](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7r1f9wh1ea3i8peks6bj.png)

So go ahead, dive into the world of hidden CSS properties, and elevate your designs to the next level!