CSS is famously forgiving: a typo doesn't break the page, it just gets skipped while the cascade keeps looking for a match. But forgiving isn't the same as invisible, and a few mistakes I make repeatedly still make me wince.
The usual suspects
I lose track of how often I catch myself doing this one:
.element {
display: flexbox; /* 🤦♂️ */
}
Similarly, I sometimes try to set a gradient without including the background property:
.gradient {
linear-gradient(45deg, rgb(50% 100% 90%), rgb(62% 85% 93%));
}
X and C sit far too close together on the keyboard, which explains why I so often mistake px for pc while typing quickly:
.element {
font-size: 16pc; /* I meant pixels! */
}
There's another slip I know other people make too — I spot it frequently in blog posts that include code snippets:
// This is not a CSS comment.
.element {
/* This is a CSS comment. */
}
Related: have you ever forgotten to wrap a CSS variable in var()? I have.
.element {
color: --primary-color;
}
Naming CSS variables is genuinely hard, and when I use some slightly wrong version of a name I chose myself, I end up with something like this:
:root {
--color-primary: #FF5722;
--color-secondary: #3E2723;
}
/* Much later on... */
.element {
color: var(--primary-color); /* 🙃 */
}
I've also pasted a snippet of CSS only to have fancy quotes break it:
.element::before {
content: “”; /* Should be "" */
}
It took me far longer than it should have to work out that the quotes were the problem.
That one reminds me of two more recurring omissions: forgetting to set the content property when using ::before or ::after, and forgetting to set an element's position before trying to offset it or change its z-index.
Why these mistakes rarely get written about
Reading a post about an impressive trick can leave you with a touch of imposter syndrome, and that's largely because posts hide the real work and the failures behind the result. I read posts like that for a living, and many — probably the vast majority — go through rounds of editing where potentially embarrassing mistakes are removed and smoothed over.
Even the most spectacular articles had to fail before they earned any ooooos and ahhhhhs, and the same holds for any app, site, or demo you come across. It's nearly unheard of for something to come out perfect on the first attempt.
Personally, I'm often more taken with the journey — warts and all — than the result, because the journey is a glimpse into how a front-end developer actually thinks. That's where the most valuable learning happens.
So what are yours?
Come on, we both know you have some. Share them so the rest of us can learn from them.



