Skip to Content
29 January, 2023

How to write best practise CSS

Table of Content

Here are some tips for writing best practice CSS:

  1. Use a CSS preprocessor: A CSS preprocessor, such as Sass, allows you to write more organized and maintainable CSS code.
  2. Use a CSS reset: A CSS reset, such as Normalize.css, helps ensure consistency across different browsers by removing default styles.
  3. Keep it organized: Group related styles together, and use meaningful and descriptive class names.
  4. Use CSS specificity wisely: Use specific selectors when necessary, but also consider using CSS inheritance to avoid overly specific selectors.
  5. Minimize the use of !important: Using !important can make your CSS code difficult to maintain, and should be used sparingly.
  6. Use shorthand properties: Shorthand properties, such as padding or margin, can simplify your CSS code and make it easier to read.
  7. Write modular CSS: Write small, reusable CSS modules that can be combined to create larger components.

By following these best practices, you can write clean, maintainable, and effective CSS code.

Free website review

Three things we would fix on your site, in writing, within a week

We have built and looked after websites for Sydney businesses since 2016, and the first thing we do with any new client is exactly this: look properly and say what we see. Send us the address and we will do the same for you. No sales sequence, no automated follow up, one honest reply.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

One working day to acknowledge, up to a week for the review. Your details stay with the Defyn team in Sydney.

Insights

The latest from our knowledge base

WordPress.com Pro Partner WooCommerce Pro Partner Shopify Certified
Free website review