DEV Community

Mursal Furqan Kumbhar
Mursal Furqan Kumbhar

Posted on

4 1

Useful CSS Shorthand

As a developer, we must try to minimize our code as much as possible, without affecting the efficiency of our program/code. Be it on front-end side, server side, back-side, database queries or design code. We should learn positive shorthand for the same. Here we are discussing some useful CSS Shorthand for developers.

Font

Instead of

font-style: italic;
font-weight: bold;
font-size: 0.8em;
line-height: 1.2;
font-family: Arial, sans-serif;
Enter fullscreen mode Exit fullscreen mode

use

font: italic bold 0.8em/1.2 Arial, sans-serif;
Enter fullscreen mode Exit fullscreen mode

Background

Instead of

background-color: #000;
background-image: url(images/bg.gif);
background-repeat: no-repeat;
background-position: left top;
Enter fullscreen mode Exit fullscreen mode

Use

background: #000 url(images/bg.gif) no-repeat left top;
Enter fullscreen mode Exit fullscreen mode

Border

Instead of

border-width: 1px;
border-style: solid;
border-color: black
Enter fullscreen mode Exit fullscreen mode

Use

border: 1px solid black;
Enter fullscreen mode Exit fullscreen mode

Margin

Instead of

margin-top: 10px;
margin-right: 15px;
margin-left: 20px;
margin: 25px;
Enter fullscreen mode Exit fullscreen mode

Use

margin: 10px 15px 20px 25px;
Enter fullscreen mode Exit fullscreen mode

Or instead of

margin-top: 10px;
margin-right: 10px;
margin-left: 10px;
margin: 10px;
Enter fullscreen mode Exit fullscreen mode

Use

margin: 10px;
Enter fullscreen mode Exit fullscreen mode

Transition

Instead of

transition-property: all;
transition-duration: 3s;
transition-timing-function: ease;
transition-delay: 1s;
Enter fullscreen mode Exit fullscreen mode

Use

transition: all 3s ease 1s;
Enter fullscreen mode Exit fullscreen mode

List

Instead of

list-style-type: disc;
list-style-position: inside;
list-style-image: url(disc.png)
Enter fullscreen mode Exit fullscreen mode

Use

list-style: disc inside url(disc.png)
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay