Tuesday, June 28, 2022
HomeWeb DevelopmentMy Dumbest CSS Errors | CSS-Tips

My Dumbest CSS Errors | CSS-Tips


All of us make errors in our code. It occurs! I do know if I had a kind of “Days Since Final Mistake” indicators hanging over my desk, a giant ol’ goose egg can be hovering above me on a regular basis. It doesn’t should be massive errors, both. My clumsy self has dedicated small errors to repos starting from typos all the best way to finish npm module directories.

Whooooooops.

That’s one of many issues I actually love about CSS: it’s forgiving as heck. If it doesn’t perceive a typo, it retains trying up the cascade seeking a match. None of that stuff the place one misplaced characters breaks a web site and takes no prisoners. Nevertheless it’s nonetheless embarrassing when CSS errors pop up!

Like this one I discover myself making far more occasions than I’d prefer to admit:

.factor {
  show: flexbox; /* 🤦‍♂️ */
}

Or after I strive setting a gradient and not using a background property:

.gradient {
  linear-gradient(45deg, rgb(50% 100% 90%), rgb(62% 85% 93%));
}

I hate how shut X and C are on a keyboard as a result of I can’t depend what number of occasions I’m blazing via one thing and mistake px for laptop items.

.factor {
  font-size: 16pc; /* I meant pixels! */
}

One other CSS mistake I catch occasionally is one I do know many other people make as a result of I spot it too typically in weblog posts with code snippets:

// This isn't a CSS remark.
.factor {
  /* This can be a CSS remark. */
}

Have you ever ever forgotten to make use of var() round a CSS variable? I certain have.

.factor {
  shade: --primary-color;
}

Talking of CSS variables, naming them is difficult (like every little thing else) and I typically use some incorrect model of a variable that I named!

:root {
  --color-primary: #FF5722;
  --color-secondary: #3E2723;
}

/* A lot afterward... */

.factor {
  shade: var(--primary-color); /* 🙃 */
}

Sure, I’ve certainly copied a snippet of CSS earlier than solely to have fancy quotes get in the best way of creating it work:

.factor::earlier than {
  content material: “”; /* Needs to be "" */
}

And, sure, I’ve spent manner too lengthy determining these quotes have been the perpetrator.

Taking a look at that final one jogs my memory that I generally overlook to set the content material property after I’m working with ::earlier than or ::after. Which jogs my memory of how I’ve forgotten to set a component’s place earlier than making an attempt to offset it or change its z-index. Critically, this stuff occur!

It’s laborious speaking about errors

Have you ever ever completed studying some weblog submit sharing some superb trick and felt some form of Imposter Syndrome? I believe that’s largely as a result of weblog posts typically masks the true work — and failures — that go into superb methods. As somebody who reads posts like that for a dwelling, I can let you know that many, if not the overwhelming majority, undergo many rounds of enhancing the place probably embarrassing errors are weeded out and smoothed over.

Even these ridiculously superior articles should fail earlier than they get all these ooooos and ahhhhhs.

The identical is true of any app, web site, demo, or no matter you occur to come back throughout. The possibilities any of them got here out good the primary time is subsequent to nothin’.

But when I’m being completely sincere with you, I’m typically extra amazed (and ) within the journey it takes to perform one thing, warts and all. The journey is a glimpse into what it’s prefer to suppose like a front-end developer. That’s the place actual (and most beneficial) studying occurs.

And all of that is merely constructing as much as what I actually wish to ask…

What are your dumbest CSS errors?

C’mon, everyone knows you’ve made some! Allow us to be taught from them!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments