aboutsummaryrefslogtreecommitdiff
path: root/htmlcssguide.html
diff options
context:
space:
mode:
Diffstat (limited to 'htmlcssguide.html')
-rw-r--r--htmlcssguide.html119
1 files changed, 47 insertions, 72 deletions
diff --git a/htmlcssguide.html b/htmlcssguide.html
index 6fc7b39..58e6c12 100644
--- a/htmlcssguide.html
+++ b/htmlcssguide.html
@@ -13,45 +13,39 @@
<h1>Google HTML/CSS Style Guide</h1>
<h2 id="Background">1 Background</h2>
-<p></p>
-
<p>This document defines formatting and style rules for HTML and CSS. It aims at
improving collaboration, code quality, and enabling supporting infrastructure.
It applies to raw, working files that use HTML and CSS, including GSS files.
Tools are free to obfuscate, minify, and compile as long as the general code
quality is maintained.</p>
-<p></p>
-
-<p></p>
-
<h2 id="General">2 General</h2>
<h3 id="General_Style_Rules">2.1 General Style Rules</h3>
<h4 id="Protocol">2.1.1 Protocol</h4>
-<p>Use the HTTPS protocol for embedded resources where possible.</p>
+<p>Use HTTPS for embedded resources where possible.</p>
-<p>Always use the HTTPS protocol (<code>https:</code>) for images and other media
+<p>Always use HTTPS (<code>https:</code>) for images and other media
files, style sheets, and scripts, unless the respective files are not available
over HTTPS.</p>
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended: omits the protocol --&gt;
-&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
+&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"&gt;&lt;/script&gt;
-&lt;!-- Not recommended: uses the HTTP protocol --&gt;
-&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
+&lt;!-- Not recommended: uses HTTP --&gt;
+&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"&gt;&lt;/script&gt;
</code></pre>
<pre><code class="language-html prettyprint">&lt;!-- Recommended --&gt;
-&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
+&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"&gt;&lt;/script&gt;
</code></pre>
<pre><code class="language-css prettyprint badcode">/* Not recommended: omits the protocol */
@import '//fonts.googleapis.com/css?family=Open+Sans';
-/* Not recommended: uses the HTTP protocol */
+/* Not recommended: uses HTTP */
@import 'http://fonts.googleapis.com/css?family=Open+Sans';
</code></pre>
@@ -59,14 +53,6 @@ over HTTPS.</p>
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
</code></pre>
-
-
-<p></p>
-
-<p></p>
-
-<p></p>
-
<h3 id="General_Formatting_Rules">2.2 General Formatting Rules</h3>
<h4 id="Indentation">2.2.1 Indentation</h4>
@@ -163,14 +149,10 @@ depends on the project&#8217;s complexity.)</p>
<p>Append action items after a colon as in <code>TODO: action item</code>.</p>
-<pre></pre>
-
<pre><code class="language-django prettyprint external">{# TODO(john.doe): revisit centering #}
&lt;center&gt;Test&lt;/center&gt;
</code></pre>
-<p></p>
-
<pre><code class="language-html prettyprint">&lt;!-- TODO: remove optional tags --&gt;
&lt;ul&gt;
&lt;li&gt;Apples&lt;/li&gt;
@@ -235,8 +217,6 @@ paragraphs, <code>a</code> elements for anchors, etc.</p>
<p>Using HTML according to its purpose is important for accessibility, reuse, and
code efficiency reasons.</p>
-<p></p>
-
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended --&gt;
&lt;div onclick="goToRecommendations();"&gt;All recommendations&lt;/div&gt;
</code></pre>
@@ -261,8 +241,6 @@ may have no way of understanding what video or audio contents are about either.<
whose purpose is purely decorative which you cannot immediately use CSS for, use
no alternative text, as in <code>alt=""</code>.)</p>
-<p></p>
-
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended --&gt;
&lt;img src="spreadsheet.png"&gt;
</code></pre>
@@ -290,8 +268,6 @@ sheets and scripts as possible from documents and templates.</p>
maintenance reasons. It is always more expensive to change HTML documents and
templates than it is to update style sheets and scripts.</p>
-<p></p>
-
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended --&gt;
&lt;!DOCTYPE html&gt;
&lt;title&gt;HTML sucks&lt;/title&gt;
@@ -340,7 +316,7 @@ The currency symbol for the Euro is &#8220;&#8364;&#8221;.
<p>Omit optional tags (optional).</p>
<p>For file size optimization and scannability purposes, consider omitting optional
-tags. The <a href="https://whatwg.org/specs/web-apps/current-work/multipage/syntax.html#syntax-tag-omission">HTML5 specification</a>
+tags. The <a href="https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission">HTML5 specification</a>
defines what tags can be omitted.</p>
<p>(This approach may require a grace period to be established as a wider guideline
@@ -374,13 +350,13 @@ tags, not just a selection.)</p>
(unless not using JavaScript).</p>
<p>Specifying <code>type</code> attributes in these contexts is not necessary as HTML5 implies
-<a href="https://whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-style-type"><code>text/css</code></a>
-and <a href="https://whatwg.org/specs/web-apps/current-work/multipage/scripting.html#attr-script-type"><code>text/javascript</code></a>
+<a href="https://html.spec.whatwg.org/multipage/obsolete.html#attr-style-type"><code>text/css</code></a>
+and <a href="https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type"><code>text/javascript</code></a>
as defaults. This can be safely done even for older browsers.</p>
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended --&gt;
&lt;link rel="stylesheet" href="https://www.google.com/css/maia.css"
- type="text/css"&gt;
+ type="text/css"&gt;
</code></pre>
<pre><code class="language-html prettyprint">&lt;!-- Recommended --&gt;
@@ -389,7 +365,7 @@ as defaults. This can be safely done even for older browsers.</p>
<pre><code class="language-html prettyprint badcode">&lt;!-- Not recommended --&gt;
&lt;script src="https://www.google.com/js/gweb/analytics/autotrack.js"
- type="text/javascript"&gt;&lt;/script&gt;
+ type="text/javascript"&gt;&lt;/script&gt;
</code></pre>
<pre><code class="language-html prettyprint">&lt;!-- Recommended --&gt;
@@ -437,7 +413,37 @@ instead of an error.)</p>
&lt;/table&gt;
</code></pre>
-<h4 id="HTML_Quotation_Marks">3.2.2 HTML Quotation Marks</h4>
+<h4 id="HTML_Line-Wrapping">3.2.2 HTML Line-Wrapping</h4>
+
+<p>Break long lines (optional).</p>
+
+<p>While there is no column limit recommendation for HTML, you may consider
+wrapping long lines if it significantly improves readability.</p>
+
+<p>When line-wrapping, each continuation line should be indented at least 4
+additional spaces from the original line.</p>
+
+<pre><code class="language-html prettyprint">&lt;md-progress-circular md-mode="indeterminate" class="md-accent"
+ ng-show="ctrl.loading" md-diameter="35"&gt;
+&lt;/md-progress-circular&gt;
+</code></pre>
+
+<pre><code class="language-html prettyprint">&lt;md-progress-circular
+ md-mode="indeterminate"
+ class="md-accent"
+ ng-show="ctrl.loading"
+ md-diameter="35"&gt;
+&lt;/md-progress-circular&gt;
+</code></pre>
+
+<pre><code class="language-html prettyprint">&lt;md-progress-circular md-mode="indeterminate"
+ class="md-accent"
+ ng-show="ctrl.loading"
+ md-diameter="35"&gt;
+&lt;/md-progress-circular&gt;
+</code></pre>
+
+<h4 id="HTML_Quotation_Marks">3.2.3 HTML Quotation Marks</h4>
<p>When quoting attributes values, use double quotation marks.</p>
@@ -588,7 +594,7 @@ padding: 0;
<p>Omit leading &#8220;0&#8221;s in values.</p>
-<p>Do not use put <code>0</code>s in front of values or lengths between -1 and 1.</p>
+<p>Do not put <code>0</code>s in front of values or lengths between -1 and 1.</p>
<pre><code class="language-css prettyprint">font-size: .8em;
</code></pre>
@@ -616,10 +622,6 @@ color: #ebc;
external sites use prefixes (as namespaces) for ID and class names. Use short,
unique identifiers followed by a dash.</p>
-<p></p>
-
-<p></p>
-
<p>Using namespaces helps preventing naming conflicts and can make maintenance
easier, for example in search and replace operations.</p>
@@ -661,10 +663,6 @@ resistance. That is, allowing and making it easy to use detection and hacks
means using detection and hacks more frequently&#8212;and more frequently is too
frequently.</p>
-<p></p>
-
-<p></p>
-
<h3 id="CSS_Formatting_Rules">4.2 CSS Formatting Rules</h3>
<h4 id="Declaration_Order">4.2.1 Declaration Order</h4>
@@ -813,11 +811,10 @@ body {
<h4 id="CSS_Quotation_Marks">4.2.8 CSS Quotation Marks</h4>
-<p>Use single quotation marks for attribute selectors and property values.</p>
-
<p>Use single (<code>''</code>) rather than double (<code>""</code>) quotation marks for attribute
-selectors or property values. Do not use quotation marks in URI values
-(<code>url()</code>).</p>
+selectors and property values.</p>
+
+<p>Do not use quotation marks in URI values (<code>url()</code>).</p>
<p>Exception: If you do need to use the <code>@charset</code> rule, use double quotation
marks&#8212;<a href="https://www.w3.org/TR/CSS21/syndata.html#charset">single quotation marks are not permitted</a>.</p>
@@ -860,28 +857,6 @@ sections with new lines.</p>
.adw-gallery {}
</code></pre>
-
-
-<p></p>
-
-<p></p>
-
-
-
-<p></p>
-
-<p></p>
-
-<pre></pre>
-
-
-
-
-
-<p></p>
-
-<p></p>
-
<h2 id="Parting_Words">Parting Words</h2>
<p><em>Be consistent.</em></p>