13
13
< h1 > Google HTML/CSS Style Guide</ h1 >
14
14
< h2 id ="Background "> 1 Background</ h2 >
15
15
16
- < p > </ p >
17
-
18
16
< p > This document defines formatting and style rules for HTML and CSS. It aims at
19
17
improving collaboration, code quality, and enabling supporting infrastructure.
20
18
It applies to raw, working files that use HTML and CSS, including GSS files.
21
19
Tools are free to obfuscate, minify, and compile as long as the general code
22
20
quality is maintained.</ p >
23
21
24
- < p > </ p >
25
-
26
- < p > </ p >
27
-
28
22
< h2 id ="General "> 2 General</ h2 >
29
23
30
24
< h3 id ="General_Style_Rules "> 2.1 General Style Rules</ h3 >
@@ -59,14 +53,6 @@ <h4 id="Protocol">2.1.1 Protocol</h4>
59
53
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
60
54
</ code > </ pre >
61
55
62
-
63
-
64
- < p > </ p >
65
-
66
- < p > </ p >
67
-
68
- < p > </ p >
69
-
70
56
< h3 id ="General_Formatting_Rules "> 2.2 General Formatting Rules</ h3 >
71
57
72
58
< h4 id ="Indentation "> 2.2.1 Indentation</ h4 >
@@ -167,8 +153,6 @@ <h4 id="Action_Items">2.3.3 Action Items</h4>
167
153
<center>Test</center>
168
154
</ code > </ pre >
169
155
170
- < p > </ p >
171
-
172
156
< pre > < code class ="language-html prettyprint "> <!-- TODO: remove optional tags -->
173
157
<ul>
174
158
<li>Apples</li>
@@ -233,8 +217,6 @@ <h4 id="Semantics">3.1.3 Semantics</h4>
233
217
< p > Using HTML according to its purpose is important for accessibility, reuse, and
234
218
code efficiency reasons.</ p >
235
219
236
- < p > </ p >
237
-
238
220
< pre > < code class ="language-html prettyprint badcode "> <!-- Not recommended -->
239
221
<div onclick="goToRecommendations();">All recommendations</div>
240
222
</ code > </ pre >
@@ -259,8 +241,6 @@ <h4 id="Multimedia_Fallback">3.1.4 Multimedia Fallback</h4>
259
241
whose purpose is purely decorative which you cannot immediately use CSS for, use
260
242
no alternative text, as in < code > alt=""</ code > .)</ p >
261
243
262
- < p > </ p >
263
-
264
244
< pre > < code class ="language-html prettyprint badcode "> <!-- Not recommended -->
265
245
<img src="spreadsheet.png">
266
246
</ code > </ pre >
@@ -288,8 +268,6 @@ <h4 id="Separation_of_Concerns">3.1.5 Separation of Concerns</h4>
288
268
maintenance reasons. It is always more expensive to change HTML documents and
289
269
templates than it is to update style sheets and scripts.</ p >
290
270
291
- < p > </ p >
292
-
293
271
< pre > < code class ="language-html prettyprint badcode "> <!-- Not recommended -->
294
272
<!DOCTYPE html>
295
273
<title>HTML sucks</title>
@@ -338,7 +316,7 @@ <h4 id="Optional_Tags">3.1.7 Optional Tags</h4>
338
316
< p > Omit optional tags (optional).</ p >
339
317
340
318
< p > For file size optimization and scannability purposes, consider omitting optional
341
- tags. The < a href ="https://whatwg.org/specs/web-apps/current-work /multipage/syntax.html#syntax-tag-omission "> HTML5 specification</ a >
319
+ tags. The < a href ="https://html.spec. whatwg.org/multipage/syntax.html#syntax-tag-omission "> HTML5 specification</ a >
342
320
defines what tags can be omitted.</ p >
343
321
344
322
< p > (This approach may require a grace period to be established as a wider guideline
@@ -372,8 +350,8 @@ <h4 id="type_Attributes">3.1.8 <code>type</code> Attributes</h4>
372
350
(unless not using JavaScript).</ p >
373
351
374
352
< p > Specifying < code > type</ code > attributes in these contexts is not necessary as HTML5 implies
375
- < a href ="https://whatwg.org/specs/web-apps/current-work/ multipage/semantics .html#attr-style-type "> < code > text/css</ code > </ a >
376
- and < a href ="https://whatwg.org/specs/web-apps/current-work /multipage/scripting.html#attr-script-type "> < code > text/javascript</ code > </ a >
353
+ < a href ="https://html.spec. whatwg.org/multipage/obsolete .html#attr-style-type "> < code > text/css</ code > </ a >
354
+ and < a href ="https://html.spec. whatwg.org/multipage/scripting.html#attr-script-type "> < code > text/javascript</ code > </ a >
377
355
as defaults. This can be safely done even for older browsers.</ p >
378
356
379
357
< pre > < code class ="language-html prettyprint badcode "> <!-- Not recommended -->
@@ -435,7 +413,37 @@ <h4 id="General_Formatting">3.2.1 General Formatting</h4>
435
413
</table>
436
414
</ code > </ pre >
437
415
438
- < h4 id ="HTML_Quotation_Marks "> 3.2.2 HTML Quotation Marks</ h4 >
416
+ < h4 id ="HTML_Line-Wrapping "> 3.2.2 HTML Line-Wrapping</ h4 >
417
+
418
+ < p > Break long lines (optional).</ p >
419
+
420
+ < p > While there is no column limit recommendation for HTML, you may consider
421
+ wrapping long lines if it significantly improves readability.</ p >
422
+
423
+ < p > When line-wrapping, each continuation line should be indented at least 4
424
+ additional spaces from the original line.</ p >
425
+
426
+ < pre > < code class ="language-html prettyprint "> <md-progress-circular md-mode="indeterminate" class="md-accent"
427
+ ng-show="ctrl.loading" md-diameter="35">
428
+ </md-progress-circular>
429
+ </ code > </ pre >
430
+
431
+ < pre > < code class ="language-html prettyprint "> <md-progress-circular
432
+ md-mode="indeterminate"
433
+ class="md-accent"
434
+ ng-show="ctrl.loading"
435
+ md-diameter="35">
436
+ </md-progress-circular>
437
+ </ code > </ pre >
438
+
439
+ < pre > < code class ="language-html prettyprint "> <md-progress-circular md-mode="indeterminate"
440
+ class="md-accent"
441
+ ng-show="ctrl.loading"
442
+ md-diameter="35">
443
+ </md-progress-circular>
444
+ </ code > </ pre >
445
+
446
+ < h4 id ="HTML_Quotation_Marks "> 3.2.3 HTML Quotation Marks</ h4 >
439
447
440
448
< p > When quoting attributes values, use double quotation marks.</ p >
441
449
@@ -586,7 +594,7 @@ <h4 id="Leading_0s">4.1.7 Leading 0s</h4>
586
594
587
595
< p > Omit leading “0”s in values.</ p >
588
596
589
- < p > Do not use put < code > 0</ code > s in front of values or lengths between -1 and 1.</ p >
597
+ < p > Do not put < code > 0</ code > s in front of values or lengths between -1 and 1.</ p >
590
598
591
599
< pre > < code class ="language-css prettyprint "> font-size: .8em;
592
600
</ code > </ pre >
@@ -614,10 +622,6 @@ <h4 id="Prefixes">4.1.9 Prefixes</h4>
614
622
external sites use prefixes (as namespaces) for ID and class names. Use short,
615
623
unique identifiers followed by a dash.</ p >
616
624
617
- < p > </ p >
618
-
619
- < p > </ p >
620
-
621
625
< p > Using namespaces helps preventing naming conflicts and can make maintenance
622
626
easier, for example in search and replace operations.</ p >
623
627
@@ -659,10 +663,6 @@ <h4 id="Hacks">4.1.11 Hacks</h4>
659
663
means using detection and hacks more frequently—and more frequently is too
660
664
frequently.</ p >
661
665
662
- < p > </ p >
663
-
664
- < p > </ p >
665
-
666
666
< h3 id ="CSS_Formatting_Rules "> 4.2 CSS Formatting Rules</ h3 >
667
667
668
668
< h4 id ="Declaration_Order "> 4.2.1 Declaration Order</ h4 >
@@ -811,11 +811,10 @@ <h4 id="Rule_Separation">4.2.7 Rule Separation</h4>
811
811
812
812
< h4 id ="CSS_Quotation_Marks "> 4.2.8 CSS Quotation Marks</ h4 >
813
813
814
- < p > Use single quotation marks for attribute selectors and property values.</ p >
815
-
816
814
< p > Use single (< code > ''</ code > ) rather than double (< code > ""</ code > ) quotation marks for attribute
817
- selectors or property values. Do not use quotation marks in URI values
818
- (< code > url()</ code > ).</ p >
815
+ selectors and property values.</ p >
816
+
817
+ < p > Do not use quotation marks in URI values (< code > url()</ code > ).</ p >
819
818
820
819
< p > Exception: If you do need to use the < code > @charset</ code > rule, use double quotation
821
820
marks—< a href ="https://www.w3.org/TR/CSS21/syndata.html#charset "> single quotation marks are not permitted</ a > .</ p >
@@ -858,26 +857,6 @@ <h4 id="Section_Comments">4.3.1 Section Comments</h4>
858
857
.adw-gallery {}
859
858
</ code > </ pre >
860
859
861
-
862
-
863
- < p > </ p >
864
-
865
- < p > </ p >
866
-
867
-
868
-
869
- < p > </ p >
870
-
871
- < p > </ p >
872
-
873
-
874
-
875
-
876
-
877
- < p > </ p >
878
-
879
- < p > </ p >
880
-
881
860
< h2 id ="Parting_Words "> Parting Words</ h2 >
882
861
883
862
< p > < em > Be consistent.</ em > </ p >
0 commit comments