Convert Figma logo to code with AI

csswizardry logoCSS-Guidelines

High-level guidelines for writing manageable, maintainable CSS

3,654
883
3,654
13

Top Related Projects

Principles of writing consistent, idiomatic CSS.

12,536

The CSS design system that powers GitHub

10,976

A mighty CSS linter that helps you avoid errors and enforce conventions.

Standards for developing consistent, flexible, and sustainable HTML and CSS.

6,233

Object Oriented CSS Framework

Quick Overview

CSS Guidelines is a comprehensive set of high-level advice and best practices for writing scalable, maintainable CSS. Created by Harry Roberts, it provides a framework for consistent, efficient, and organized CSS development across projects and teams.

Pros

  • Offers a holistic approach to CSS architecture and organization
  • Promotes consistency and maintainability in large-scale projects
  • Provides clear, actionable advice for common CSS challenges
  • Regularly updated to reflect modern CSS practices and techniques

Cons

  • May be overwhelming for beginners or small projects
  • Some guidelines may conflict with personal or team preferences
  • Requires discipline and team buy-in for effective implementation
  • Doesn't cover every possible CSS scenario or edge case

Getting Started

To get started with CSS Guidelines, follow these steps:

  1. Visit the GitHub repository: csswizardry/CSS-Guidelines
  2. Read through the README.md file for an overview of the guidelines
  3. Explore the individual sections in the repository for detailed advice on specific topics
  4. Consider implementing the guidelines gradually in your projects, starting with the most relevant sections for your needs
  5. Share the guidelines with your team and discuss how to adapt them to your specific workflow and requirements

Note: CSS Guidelines is not a code library, but rather a set of best practices and recommendations. There are no code examples or installation steps required. The guidelines are meant to be read, understood, and applied to your CSS development process.

Competitor Comparisons

Principles of writing consistent, idiomatic CSS.

Pros of idiomatic-css

  • More comprehensive and detailed guidelines
  • Includes specific examples for various CSS scenarios
  • Provides rationale for each recommendation

Cons of idiomatic-css

  • Less frequently updated compared to CSS-Guidelines
  • May be overwhelming for beginners due to its depth

Code Comparison

idiomatic-css:

.selector,
.selector-secondary,
.selector[type="text"] {
    padding: 15px;
    margin: 0 0 15px;
    background-color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff;
}

CSS-Guidelines:

.foo,
.foo--bar,
.baz {
    display: block;
    padding: 1em;
    margin-bottom: 1em;
}

Summary

Both repositories offer valuable CSS guidelines, but they differ in approach and depth. idiomatic-css provides more comprehensive and detailed recommendations, making it suitable for experienced developers seeking in-depth guidance. CSS-Guidelines, on the other hand, offers a more concise and beginner-friendly approach, focusing on high-level principles and best practices.

The code comparison shows that idiomatic-css tends to provide more specific examples with detailed property declarations, while CSS-Guidelines emphasizes simplicity and readability in its examples.

Ultimately, the choice between these guidelines depends on the developer's experience level and project requirements. Both repositories contribute significantly to promoting consistent and maintainable CSS coding practices.

12,536

The CSS design system that powers GitHub

Pros of Primer CSS

  • Actively maintained and regularly updated
  • Comprehensive component library with extensive documentation
  • Built-in support for design systems and theming

Cons of Primer CSS

  • Larger file size and potential performance impact
  • Steeper learning curve due to its extensive features
  • More opinionated, which may limit flexibility in some cases

Code Comparison

CSS-Guidelines example:

.c-button {
  display: inline-block;
  padding: 1em;
  background-color: #eee;
}

Primer CSS example:

.btn {
  display: inline-block;
  padding: $spacer-2 $spacer-3;
  font-size: $body-font-size;
  font-weight: $font-weight-bold;
  line-height: $lh-condensed-ultra;
  color: $text-white;
  background-color: $bg-blue-5;
  border: 1px solid $border-blue-5;
  border-radius: $border-radius;
}

CSS-Guidelines focuses on providing a set of best practices and naming conventions, while Primer CSS offers a more comprehensive and opinionated approach with pre-built components and utility classes. CSS-Guidelines is lighter and more flexible, whereas Primer CSS provides a complete design system with consistent styling across components.

10,976

A mighty CSS linter that helps you avoid errors and enforce conventions.

Pros of stylelint

  • Actively maintained and regularly updated
  • Extensive set of built-in rules for linting CSS
  • Highly configurable and customizable

Cons of stylelint

  • Steeper learning curve for configuration
  • Requires additional setup and integration into development workflow

Code Comparison

CSS-Guidelines provides general best practices:

.selector {
  property: value;
  property: value;
}

stylelint enforces specific rules:

{
  "rules": {
    "indentation": 2,
    "color-hex-case": "lower",
    "selector-class-pattern": "^[a-z]+(-[a-z]+)*$"
  }
}

Summary

CSS-Guidelines offers a set of best practices and guidelines for writing CSS, while stylelint is a powerful linting tool that enforces coding standards. CSS-Guidelines is more of a reference document, whereas stylelint is an active part of the development process. stylelint provides more granular control over code style but requires more setup. CSS-Guidelines is easier to adopt but less enforceable. The choice between them depends on project needs and team preferences.

Standards for developing consistent, flexible, and sustainable HTML and CSS.

Pros of Code Guide

  • More comprehensive, covering HTML, CSS, and JavaScript
  • Includes examples for each guideline, making it easier to understand
  • Regularly updated with the latest best practices

Cons of Code Guide

  • Less focused on CSS-specific guidelines
  • May be overwhelming for beginners due to its broad scope
  • Lacks in-depth explanations for some recommendations

Code Comparison

CSS-Guidelines:

.selector {
    property: value;
    property: value;
}

Code Guide:

.selector {
  property: value;
  property: value;
}

The main difference is the indentation: CSS-Guidelines uses 4 spaces, while Code Guide uses 2 spaces.

Key Differences

  • CSS-Guidelines focuses solely on CSS, while Code Guide covers multiple languages
  • CSS-Guidelines provides more detailed explanations for its recommendations
  • Code Guide offers a more concise set of rules, making it easier to implement quickly
  • CSS-Guidelines emphasizes scalability and maintainability for large projects
  • Code Guide aims to be a general-purpose style guide for various project sizes

Both repositories offer valuable insights into code organization and best practices. CSS-Guidelines is ideal for CSS-intensive projects, while Code Guide provides a broader set of guidelines for web development in general. The choice between them depends on the specific needs of your project and team preferences.

6,233

Object Oriented CSS Framework

Pros of OOCSS

  • Focuses on modular, reusable CSS components
  • Emphasizes separation of structure and skin
  • Provides a comprehensive methodology for large-scale CSS architecture

Cons of OOCSS

  • Can lead to more verbose HTML with multiple classes
  • May have a steeper learning curve for beginners
  • Less emphasis on specific naming conventions compared to CSS-Guidelines

Code Comparison

OOCSS approach:

.btn { /* Base button styles */ }
.btn-primary { /* Primary button styles */ }
.btn-large { /* Large button styles */ }

CSS-Guidelines approach:

.c-btn { /* Base button styles */ }
.c-btn--primary { /* Primary button modifier */ }
.c-btn--large { /* Large button modifier */ }

The OOCSS approach uses separate classes for different button variations, while CSS-Guidelines uses BEM-like naming conventions with modifiers.

Both repositories offer valuable insights into CSS best practices, with OOCSS focusing more on object-oriented principles and CSS-Guidelines providing a comprehensive style guide. CSS-Guidelines offers more detailed naming conventions and formatting rules, while OOCSS emphasizes modularity and scalability. Developers should consider their project requirements and team preferences when choosing between these approaches.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

General CSS notes, advice and guidelines


The guidelines have moved: cssguidelin.es