Forum Moderators: Robert Charlton & goodroi
Our HTML and CSS Style Guide, just like other Google style guides, deals with a lot of formatting-related matters. It also hints at best practices so to encourage developers to go beyond indentation. Many style guide authors know the underlying motivation from the question whether to describe the code they write—or to prescribe what code they want to write. Not surprisingly then, in our HTML and CSS style guide you’ll find both (as much as you’ll still find a lot of different development styles in our not entirely small code base).
Let's not turn this into a Google-bashing thread.
Indentation: Indent by 2 spaces at a time.
Capitalization: Use only lowercase.
Alphabetize declarations.
Omit the protocol from embedded resources.
Omit type attributes for style sheets and scripts.
<link href='http://www2.blogger.com/widgets/3319451950-blogarchive.css' rel='stylesheet' type='text/css'/>
Use HTML5 / (It is recommended to use HTML, as text/html. Do not use XHTML. XHTML, as application/xhtml+xml, lacks both browser and infrastructure support and offers less room for optimization than HTML.)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Do not use entity references. / There is no need to use entity references like —, ”, or ☺, assuming the same encoding (UTF-8) is used for files and editors as well as among teams.
Great code has many attributes. It’s effective, efficient, maintainable, elegant.
Use 3 character hexadecimal notation where possible / For color values that permit it, 3 character hexadecimal notation is shorter and more succinct.
Use a space after a property name’s colon. / Always use a single space between property and value (but no space between property and colon) for consistency reasons.
margin:0;
text-transform:uppercase;
letter-spacing:.1em;
font: normal normal 78% Arial, sans-serif;
color: #666666;
[edited by: Robert_Charlton at 5:47 am (utc) on May 3, 2012]
[edit reason] moved post from another location [/edit]
The question to ask is WHY "They're volunteering coding practices" given they never volunteer anything.
These have nothing to do with ranking or SEO.
They are the guidelines that engineers at Google have to follow when building Google's own websites. They are intended to ease development, reduce bugs, promote brevity, and make code understandable to other engineers.
They are the guidelines that engineers at Google have to follow when building Google's own websites.
The question to ask is WHY "They're volunteering coding practices" given they never volunteer anything.
Many style guide authors know the underlying motivation from the question whether to describe the code they write—or to prescribe what code they want to write.
lucy24 wrote:
Are they nuts? I'm not writing a CSS index, I'm writing a stylesheet. Declarations are grouped thematically, so I can find them: existing tags (format of <a> links, <em>, that kind of thing) headers, paragraphs, lists, tables, character modifiers...
AndyA wrote:
I'm also concerned about not using closing tags for paragraphs, which as far as I know is still a recommended practice.
zdgn wrote:
Besides, I think some of Google's silly 'guidelines' - rule sorting or unminifieds or "meaningful" annotations - are plain self-serving to Googlebot [...]
I'm also concerned about not using closing tags for paragraphs, which as far as I know is still a recommended practice.
<p>This paragraph was written for Google to show what Google sees.</p>
Would become: <p>Thi parag wa writ fo Goo to sh wha Goo see
Sgt_Kickaxe wrote:
Proper formatting and completeness isn't optional.