CSS Magic: 5 Underused CSS Properties You Should Know

CSS Magic: 5 Underused CSS Properties You Should Know


Cascading Style Sheets (CSS) is a powerful tool in a developer's arsenal, capable of bringing to life even the most complex web designs. While most of us are familiar with the commonly used properties, CSS has a vast range of capabilities that are often overlooked. In this article, we delve into five underused CSS properties that can enhance your web designs.

1. CSS `currentColor` Keyword

The `currentColor` keyword represents the value of an element's `color` property, allowing you to create consistent color schemes with less code.

  1. .element {
  2. color: #f06d06;
  3. border: 1px solid currentColor;
  4. box-shadow: 0 0 10px currentColor;
  5. }

This code will render an element with the color, border, and shadow all in the same color, thus maintaining visual consistency.

2. CSS `object-fit` Property

The `object-fit` property allows the content of replaced elements, such as `img`, `video`, or `object`, to be resized and fitted.

  1. img {
  2. object-fit: cover;
  3. }

For example, `object-fit: cover;` resizes the content to fill the element's content box, preserving its aspect ratio and clipping the overflow content.

3. CSS `clip-path` Property

The `clip-path` property can create complex shapes by clipping an element to a basic shape, polygon, or SVG source.

  1. .shape {
  2. clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  3. }

This code will clip an element into a diamond shape, making for an interesting visual effect.

4. CSS `calc()` Function

The `calc()` function can perform calculations to determine CSS property values, accepting `+`, `-`, `*`, and `/` as operators.

  1. .element {
  2. width: calc(100% - 2em);
  3. }

This code will render an element that is always 2em less than the full width, useful for maintaining consistent padding or margins.

5. CSS Variables (Custom Properties)

CSS variables, or custom properties, store specific values for reuse throughout a document, making your stylesheets more manageable.

  1. :root {
  2. --main-color: #f06d06;
  3. }
  5. .element {
  6. color: var(--main-color);
  7. }

This code defines a color variable and applies it to an element. Changing the variable's value will affect all instances of its use, allowing for effortless theme changes.


While CSS has a myriad of properties, it's easy to forget some of the less commonly used but equally powerful ones. Utilizing these underused CSS properties can simplify your code, streamline your workflow, and open up new possibilities for creative web designs. Happy coding!

We use cookies to improve your browsing experience. By continuing to use this website, you consent to our use of cookies. Learn More