DEV Community

Cover image for 7 Common CSS Mistakes Junior Frontend Developers Make (And How to Fix Them)
Ndeye Fatou Diop
Ndeye Fatou Diop

Posted on • Edited on • Originally published at frontendjoy.com

12

7 Common CSS Mistakes Junior Frontend Developers Make (And How to Fix Them)

Mistake #1: Overusing !important.

  • ❗️Problem: Makes style overrides a nightmare
  • 🛠️ Fix: Boost selector specificity or reorganize your code.

Mistake 1

Mistake #2: Overcomplicating selectors.

  • ❗️Problem: Complex selectors are hard to read and harder to override.
  • 🛠️ Fix: Opt for the lowest specificity that will solve your issue.

Mistake 2

Mistake #3: Having redundant declarations.

  • ❗️Problem: Re-declaring default values make your code cluttered.
  • 🛠️ Fix: Set property values only when they differ from the default ones.

Mistake 3

Mistake #4: Not using shorthand properties.

  • ❗️Problem: Makes your code unnecessarily cluttered.
  • 🛠️ Fix: Use CSS shorthand whenever applicable.

Mistake 4

Mistake #5: Setting unnecessarily high z-index.

  • ❗️Problem: z-index conflicts may arise, often requiring a higher one.
  • 🛠️ Fix: Leverage stacking contexts.

Mistake 5

Mistake #6: Using inconsistent values.

  • ❗️Problem: UI inconsistency.
  • 🛠️ Fix: Stick to consistent values for a polished look.

Mistake 6

Mistake #7: Using CSS features only supported by a few browsers.

  • ❗️Problem: Your code may not work correctly on some browsers.
  • 🛠️ Fix: Check first canIUse and provide fallbacks if necessary.

Mistake 7

——

Thank you for reading this post 🙏.

Leave a comment 📩 to share a CSS mistake that you have made or seen new devs make.

And Don't forget to Drop a "💖🦄🔥".

If you like articles like this, join my FREE newsletter, FrontendJoy, or find me on X/Twitter.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
_ndeyefatoudiop profile image
Ndeye Fatou Diop

Thanks for suggesting this. I was hesitant to add it because it looked like a really new feature (I never used it myself since I really on scss modules) but thanks for suggesting it ❤️

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

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

Okay