What’re Your Top 4 CSS Properties?

Publikováno: 10.9.2025

Everyone has a different opinion which is great because it demonstrates the messy, non-linear craft that is thinking like a front-end developer.


What’re Your Top 4 CSS Properties? originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

Celý článek

That’s what Donnie D’Amato asks in a recent post:

You are asked to build a website but you can use only 4 CSS properties, what are those?

This really got the CSS-Tricks team talking. It’s the nerdy version of “if you could only take one album with you on a remote island…” And everyone had a different opinion which is great because it demonstrates the messy, non-linear craft that is thinking like a front-end developer.

Seems like a pretty straightforward thing to answer, right? But like Donnie says, this takes some strategy. Like, say spacing is high on your priority list. Are you going to use margin? padding? Perhaps you’re leaning into layout and go with gap as part of a flexbox direction… but then you’re committing to display as one of your options. That can quickly eat up your choices!

Our answers are pretty consistent, but converged even more as the discussion wore on and all of us were coming at it with different priorities. I’ll share each person’s “gut” reaction because I like how raw it is. I think you’ll see that there’s always a compromise in the mix, but those compromises really reveal a person’s cards as far as what they think is most important in a situation with overly tight constraints.


Juan Diego Rodriguez

Juan and I came out pretty close to the same choices, as we’ll see in a bit:

  • font: Typography is a priority and we get a lot of constituent properties with this single shorthand.
  • padding: A little padding makes things breath and helps with visual separation.
  • background: Another shorthand with lots of styling possibilities in a tiny package.
  • color: More visual hierarchy.

But he was debating with himself a bit in the process:

Thinking about switching color with place-items, since it works in block elements. grid would need display, though).

Ryan Trimble

Ryan’s all about that bass structure:

  • display: This opens up a world of layouts, but most importantly flex.
  • flex-direction: It’s a good idea to consider multi-directional layouts that are easily adjustable with media queries.
  • width: This helps constrain elements and text, as well as divide up flex containers.
  • margin: This is for spacing that’s bit more versatile than gap, while also allowing us to center elements easily.

And Ryan couldn’t resist reaching a little out of bounds:

For automatic color theme support, and no extra CSS properties required: <meta name="color-scheme" content="dark light"> 

Danny Schwarz

Every team needs a wild card:

On the contrary I think I’d choose fontpadding, and color. I wouldn’t even choose a 4th.

  • font: This isn’t a big surprise if you’re familiar with Danny’s writing.
  • padding: So far, Ryan’s the only one to eschew padding as a core choice!
  • color: Too bad this isn’t baked right into font!

I’ll also point out that Danny soon questioned his decision to use all four choices:

I supposed we’d need width to achieve a good line length.

Sunkanmi Fafowora

This is the first list to lean squarely into CSS Grid, allowing the grid shorthand to take up a choice in favor of having a complete layout system:

  • font: This is a popular one, right?
  • display: Makes grid available
  • grid: Required for this display approach
  • color: For sprinkling in text color where it might help

I love that Ryan and Sunkanmi are thinking in terms of structure, albeit in very different ways for different reasons!

Zell Liew

In Zell’s own words: “Really really plain and simple site here.”

  • font: Content is still the most important piece of information.
  • max-width: Ensures type measure is ok.
  • margin: Lets me play around with spacing.
  • color: This ensures there’s no pure black/white contrast that hurts the eyes. I’d love for background as well, but we only have four choices.

But there’s a little bit of nuance in those choices, as he explains: “But I’d switch up color for background on sites with more complex info that requires proper sectioning. In that case I’d also switch margin with padding.”

Amit Sheen

Getting straight to Amit’s selections:

  • font
  • color
  • background
  • color-scheme

The choices are largely driven by wanting to combat default user agent styles:

The thing is, if we only have four properties, we end up relying heavily on the user agents, and the only thing I’d really want to change is the fonts. But while we are at it, let’s add some color control. I’m not sure how much I’d actually use them, but it would be good to have them available.

Geoff Graham

Alright, I’m not quite as exciting now that you’ve seen everyone else’s choices. You’ll see a lot of overlap here:

  • font: A shorthand for a whopping SEVEN properties for massaging text styles.
  • color: Seems like this would come in super handy for establishing a visual hierarchy and distinguishing one element from another.
  • padding: I can’t live without a little breathing room between an element’s content box and its inner edge.
  • color-scheme: Good minimal theming that’ll work nicely alongside color and support the light-dark() function.

Clearly, I’m all in on typography. That could be a very good thing or it could really constrain me when it comes to laying things out. I really had to fight the urge to use display because I always find it incredibly useful for laying things out side-by-side that wouldn’t otherwise be possible with block-level elements.


Your turn!

Curious minds want to know! Which four properties would you take with you on a desert island?


What’re Your Top 4 CSS Properties? originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace