Golden rule
Every line of code should appear to is written by a single person, no matter the number of contributors.
1.Syntax
- Use soft tabs with both Spaces-they ' re the only-to-guarantee code renders the same in any environment.
- When grouping selectors, keep individual selectors to a.
- Include one space before the opening brace of declaration blocks for legibility.
- Place closing braces of declaration blocks in a new line.
- Include one space after:for each declaration.
- Each of the declaration should appear on its own line for more accurate error reporting.
- End all declarrations with a semi-colon. The last declaration was optional, but your code was more error prone without it.
- Comma-separated property values should include a space after each Comma (e.g., Box-shadow).
- Don ' t includes spaces after commas within RGB (), Rgba (), HSL (), Hsla (), rect ().
- Don ' t prefix property values or color parameters with a leading zero. e.g. 5px;
- #fff. Not #FFF. Not #ffffff.
- Quote attribute values in selectors.e.g., inpput[type= "text"].
- Avoid 0px, just 0. e.g., margin:0;
2.Declaration Order
- Related property declarations should is grouped together following the order:
- Positioning
- Box model
- Typographic
- Visual
- Po
3.Language attribute
4.Character encoding
5.CSS and JavaScript includes
- Typically there is no need to specify a type when including CSS and JavaScript files as text/css and Text/javascript are T Here rerspictive defaults
- <link rel= "stylesheets href=" Code-guide.css ">
- <script src=code-guide.js "></script>
6.Practicality over Purity
- Strive to maintain HTML standards and semantics, but not at the expense of practicality. Use the least amount of markup with the fewest intricacies whenever possible.
7.Attribute Order
- HTML attributes should come in this particular order for easier reading of code.
- Class
- ID, name
- data-*
- SRC, for, type, href, value
- Title, Alt
- Role, aria-*
- Classes make to great reusable components, so they come first. Ids is more specific and should is used sparingly, so they come second.
8.Boolean attributes
- A Boolean attributes is one that needs no declared value
- e.g.: <input type= "Text" disabled>
9.Reducing markup
- Whenever possible, avoid superfluous parent elements when writing HTML.
10.JavaScript generated markup
- Writing markup in JavaScript file makes the content harder to find, harder to edit, and less performant. Avoid it whenever possible.
Code Guide (CSS)