code-guide
Standards for developing consistent, flexible, and sustainable HTML and CSS.
Top Related Projects
Principles of writing consistent, idiomatic CSS.
JavaScript Style Guide
Principles of Writing Consistent, Idiomatic JavaScript
High-level guidelines for writing manageable, maintainable CSS
:art: A JavaScript Quality Guide
Style guides for Google-originated open-source projects
Quick Overview
Code Guide is a set of standards and best practices for developing flexible, durable, and sustainable HTML and CSS. Created by @mdo, it aims to improve code quality, consistency, and maintainability across projects.
Pros
- Provides clear guidelines for writing clean and consistent HTML and CSS
- Helps teams establish a common coding style and improve collaboration
- Addresses common pitfalls and best practices in front-end development
- Regularly updated to reflect modern web development standards
Cons
- Some guidelines may be opinionated and not universally agreed upon
- Might require additional effort to implement and enforce in existing projects
- Does not cover advanced CSS methodologies or frameworks
- Limited focus on JavaScript best practices
Getting Started
To start using the Code Guide in your project:
- Visit the Code Guide repository
- Read through the guidelines and best practices
- Consider creating a customized version for your team or project
- Implement the guidelines in your HTML and CSS files
- Use linting tools like ESLint or Stylelint to enforce the rules automatically
Competitor Comparisons
Principles of writing consistent, idiomatic CSS.
Pros of idiomatic-css
- More comprehensive and detailed guidelines
- Includes explanations and rationale for each rule
- Provides examples of both good and bad practices
Cons of idiomatic-css
- Less frequently updated compared to code-guide
- 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;
}
code-guide:
.selector {
padding: 15px;
margin-bottom: 15px;
background-color: rgba(0, 0, 0, 0.5);
box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff;
}
Summary
Both idiomatic-css and code-guide are valuable resources for CSS coding standards. idiomatic-css offers more in-depth guidelines and explanations, making it suitable for developers seeking a comprehensive understanding of CSS best practices. On the other hand, code-guide provides a more concise set of rules, which may be preferable for quick reference or for teams looking for a simpler standard to follow. The code comparison shows that idiomatic-css tends to group related selectors, while code-guide focuses on individual selectors, reflecting their different approaches to CSS organization.
JavaScript Style Guide
Pros of JavaScript
- More comprehensive and detailed, covering a wide range of JavaScript-specific topics
- Regularly updated with contributions from a large community
- Includes explanations and examples for each rule
Cons of JavaScript
- Can be overwhelming for beginners due to its extensive nature
- Focuses solely on JavaScript, lacking guidance for other web technologies
- Some rules may be opinionated and not universally accepted
Code Comparison
Code Guide:
<div class="modal">
<h1 class="modal-title">Title</h1>
<p class="modal-body">Hello World!</p>
</div>
JavaScript:
const greeting = 'Hello World!';
const modal = {
title: 'Title',
body: greeting
};
function showModal({ title, body }) {
// Implementation
}
The Code Guide example focuses on HTML structure and class naming, while the JavaScript example demonstrates object structuring and function parameter destructuring.
Summary
Code Guide provides a broader, more general set of guidelines for HTML and CSS, making it suitable for beginners and quick reference. JavaScript offers an in-depth, JavaScript-specific style guide with extensive rules and explanations, ideal for teams seeking consistent JavaScript coding practices. The choice between the two depends on the project's scope and the team's needs.
Principles of Writing Consistent, Idiomatic JavaScript
Pros of idiomatic.js
- More comprehensive JavaScript-specific guidelines
- Detailed explanations and rationale for each rule
- Active community contributions and discussions
Cons of idiomatic.js
- Focused solely on JavaScript, limiting its applicability
- May be overwhelming for beginners due to its depth
Code Comparison
idiomatic.js:
var foo = {
bar: function() {
// ...
},
baz: function() {
// ...
}
};
code-guide:
<nav class="navbar">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
Key Differences
- Scope: idiomatic.js focuses exclusively on JavaScript, while code-guide covers HTML, CSS, and general coding practices.
- Depth: idiomatic.js provides more in-depth JavaScript guidelines, whereas code-guide offers broader, more general coding principles.
- Format: idiomatic.js is presented as a single, detailed document, while code-guide is organized into separate sections for different languages and concepts.
Similarities
- Both aim to improve code quality and consistency
- Open-source projects with community involvement
- Provide examples to illustrate best practices
Use Cases
- idiomatic.js: Ideal for JavaScript-heavy projects or teams looking to standardize their JavaScript coding style
- code-guide: Better suited for full-stack developers or projects involving multiple languages and technologies
High-level guidelines for writing manageable, maintainable CSS
Pros of CSS-Guidelines
- More comprehensive coverage of CSS-specific topics
- Includes detailed sections on naming conventions and BEM methodology
- Provides practical examples and explanations for each guideline
Cons of CSS-Guidelines
- Less focus on general coding practices and other languages
- May be overwhelming for beginners due to its depth and length
- Last updated in 2016, potentially missing newer CSS features and best practices
Code Comparison
CSS-Guidelines:
.c-button {
display: inline-block;
padding: 1em;
}
.c-button--primary {
background-color: #0070c9;
}
Code Guide:
.btn {
display: inline-block;
padding: 1rem;
}
.btn-primary {
background-color: #0070c9;
}
Both repositories provide valuable guidelines for writing clean, maintainable CSS code. CSS-Guidelines offers a more in-depth exploration of CSS-specific topics, including naming conventions and methodologies like BEM. It provides detailed explanations and examples for each guideline, making it an excellent resource for intermediate to advanced CSS developers.
Code Guide, on the other hand, offers a broader perspective on coding practices, covering HTML, CSS, and some general principles. It's more concise and easier to digest, making it suitable for beginners or those looking for quick reference.
The code comparison shows slight differences in naming conventions, with CSS-Guidelines following BEM methodology more strictly. Both examples demonstrate clean, readable code structure.
:art: A JavaScript Quality Guide
Pros of js
- More comprehensive JavaScript-specific guidelines
- Includes modern JS practices and ES6+ features
- Provides detailed explanations and rationales for recommendations
Cons of js
- Focuses solely on JavaScript, lacking guidance for HTML/CSS
- May be overwhelming for beginners due to its depth and complexity
- Less emphasis on general coding principles and practices
Code Comparison
js:
const foo = 1
let bar = foo
bar = 9
console.log(foo, bar) // => 1, 9
code-guide:
<div class="modal">
<h1 class="modal-title">This is a modal</h1>
<p class="modal-body">Hello there!</p>
</div>
Summary
js is a comprehensive JavaScript style guide, offering in-depth recommendations for modern JS development. It excels in providing detailed explanations and covering advanced topics. However, it lacks guidance for other web technologies and may be too complex for beginners.
code-guide, on the other hand, offers a broader perspective on web development, covering HTML, CSS, and basic JavaScript. It provides simpler, more general coding principles that are accessible to developers of all levels. While less detailed in JavaScript-specific areas, it offers a well-rounded approach to web development practices.
Choose js for in-depth JavaScript guidance or code-guide for a more holistic web development style guide.
Style guides for Google-originated open-source projects
Pros of styleguide
- Comprehensive coverage of multiple programming languages
- Detailed explanations and rationale for style choices
- Regularly updated and maintained by Google engineers
Cons of styleguide
- Can be overwhelming due to its extensive nature
- May not be suitable for smaller projects or teams
- Some guidelines may be specific to Google's internal practices
Code comparison
code-guide (HTML):
<div class="module">
<h3 class="module-title">Example</h3>
<p class="module-content">Content here</p>
</div>
styleguide (HTML):
<div class="module">
<h3>Example</h3>
<p>Content here</p>
</div>
The code-guide example uses more specific class names, while the styleguide example keeps it simpler. This reflects the different approaches: code-guide focuses on maintainability and scalability, while styleguide emphasizes simplicity and consistency across large codebases.
Both repositories provide valuable guidance for code style and best practices. code-guide is more focused on front-end development, particularly HTML and CSS, while styleguide covers a broader range of languages and is more suitable for larger teams and projects. The choice between them depends on the specific needs and scale of your development efforts.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Code Guide
Standards for developing consistent, flexible, and sustainable HTML and CSS.
Start reading â
Setup
Code Guide is built on Jekyll and hosted on GitHub Pages. To install Jekyll:
gem install jekyll
To start the local server:
jekyll serve
Open localhost:4000
in your browser.
License
Released under MIT by, and copyright, @mdo.
Translations
Translations are maintained by their creators and may not always be up to date with the original here.
- Chinese - Translated by Zoom Zhao
- Chinese - Translated by Wang Sai
- Dutch - Translated by Chun Fei Lung
- French - Translated by Tim Carry
- German - Translated by BackendButters
- German - Translated by Philip Brembeck
- Hindi - Translated by Hidaytullah Rahmani
- Indonesian - Translated by Steven Sinatra
- Japanese - Translated by Kia King Ishii
- Korean - Translated by Aliencube
- Persian - Translated by Arash Hatami
- Polish - Translated by Åukasz Bondarewicz
- Portuguese - Translated by Diego Eis
- Romanian - Translated by Valeriu Mazare
- Russian - Translated by Eugene Abrosimov
- Spanish - Translated by Hans Felix
- Traditional Chinese - Translated by Yuming Cheung
Have a translation you'd like to link to? Open a pull request to add it here. Be sure to keep it alphabetical.
<3
Top Related Projects
Principles of writing consistent, idiomatic CSS.
JavaScript Style Guide
Principles of Writing Consistent, Idiomatic JavaScript
High-level guidelines for writing manageable, maintainable CSS
:art: A JavaScript Quality Guide
Style guides for Google-originated open-source projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot