Google HTML/CSS Style Guide
5
Put the opening brace on the same line as the final selector, with one space before the brace.
Selector and declaration separation
Start a new line for each selector and declaration.
h1, h2, h3 { font-weight: normal; line-height: 1.2; }
Rule separation
Put a blank line between rules.
html { background: #fff; } body { margin: auto; width: 50%; }
CSS quotation marks
Use single quotation marks for attribute selectors and property values. Do not quote URI values inside
url()
. If
@charset
is used, it requires double quotation marks.
@import url(https://www.google.com/css/maia.css); html { font-family: 'open sans', arial, sans-serif; }
7. CSS meta rules
Section comments
Grouping style-sheet sections with comments is optional. When used, separate logical sections with blank lines.
/* Header */ .adw-header {} /* Footer */ .adw-footer {} /* Gallery */ .adw-gallery {}
8. Practical review checklist
I
Use HTTPS for embedded resources where possible.
I
Indent with two spaces; never use tabs or mixed indentation.
I
Keep code lowercase except strings.
I
Remove trailing whitespace.
I
Use UTF-8 without a BOM.
I
Use TODO: for action items.
I
Start HTML documents with .
I
Use valid and semantic HTML.
I
Provide meaningful alternative content for multimedia.
I
Keep structure, presentation, and behavior separate.
I
Use double quotes for HTML attributes.
I
Prefer short, meaningful, hyphen-separated CSS class names.
I
Avoid unnecessary IDs and ID selectors.
I
Use CSS shorthand where practical.
I
Omit units after zero values unless required.
I
Include leading zeroes for fractional values.
I
Avoid !important and CSS hacks.
I
Use consistent declaration ordering.
I
End every CSS declaration with a semicolon.
I
Use consistent spacing around selectors, braces, properties, and values.
I
Separate CSS rules with blank lines.