-
Notifications
You must be signed in to change notification settings - Fork 709
/
Copy pathOverview.html
1643 lines (1197 loc) · 65 KB
/
Overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Line Grid Module Level 1</title>
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<style type="text/css">
.sidenote-block {
border: 1px solid gray;
margin: auto;
text-align: left;
padding: 4pt;
position: relative;
max-width: 400pt;
}
.sidenote-body {
margin-left: 120pt;
font-size: 12pt;
line-height: 18pt;
}
.sidenote-note {
font-size: 10pt;
line-height: 18pt;
position: absolute; left: 4pt; top: 4pt;
width: 110pt;
}
</style>
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/">
<img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72">
</a>
</p>
<h1 class="p-name no-ref" id="title">CSS Line Grid Module Level 1</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft,
<time class="dt-updated" datetime="2015-01-14">14 January 2015</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:</dt>
<dd><a class="u-url" href="http://dev.w3.org/csswg/css-line-grid/">http://dev.w3.org/csswg/css-line-grid/</a></dd>
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/css-line-grid-1/">http://www.w3.org/TR/css-line-grid-1/</a></dd>
<dt>Previous Versions:</dt>
<dd><a href="http://www.w3.org/TR/2014/WD-css-line-grid-1-20140916/" rel="previous">http://www.w3.org/TR/2014/WD-css-line-grid-1-20140916/</a></dd>
<dt>Feedback:</dt>
<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-line-grid%5D%20feedback">www-style@w3.org</a> with subject line “<kbd>[css-line-grid] <var>… message topic …</var></kbd>” (<a href="http://lists.w3.org/Archives/Public/www-style/" rel="discussion">archives</a>)</span></dd>
<dt>Issue Tracking:</dt>
<dd><a href="#issues-index">Inline In Spec</a></dd>
<dt class="editor">Editors:</dt>
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-url url" href="http://fantasai.inkedblade.net/contact">Elika Etemad</a> (<span class="p-org org">Invited Expert</span>)</div>
</dd>
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:kojiishi@gluesoft.co.jp">Koji Ishii</a> (<span class="p-org org">Invited Expert</span>)</div>
</dd>
<dd class="editor">
<div class="p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:stearns@adobe.com">Alan Stearns</a> (<span class="p-org org">Adobe Systems, Inc.</span>)</div>
</dd>
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2014 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This module contains CSS features for aligning content to a baseline grid.</p>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
</p>
<p>
The (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-line-grid%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href="http://www.w3.org/Mail/Request">instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-line-grid” in the subject,
preferably like this:
“[css-line-grid] <em>…summary of comment…</em>”
</p>
<p>
This document was produced by the <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a>
(part of the <a href="http://www.w3.org/Style/">Style Activity</a>).
</p>
<p>
This document was produced by a group operating under
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.
</p>
<p>
This document is governed by the <a href="http://www.w3.org/2014/Process-20140801/">1 August 2014 W3C Process Document</a>.
</p></div>
<div data-fill-with="at-risk"></div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">
Introduction</span></a>
<ul class="toc">
<li><a href="#context"><span class="secno">1.1</span> <span class="content">
Background</span></a></li>
<li><a href="#placement"><span class="secno">1.2</span> <span class="content">
Module Interactions</span></a></li>
<li><a href="#values"><span class="secno">1.3</span> <span class="content">
Values</span></a></li>
</ul>
</li>
<li><a href="#line-grid-property"><span class="secno">2</span> <span class="content">
Defining a <span data-dfn-type="dfn" data-noexport="">Line Grid</span>: the <span class="property" data-link-type="propdesc" title="line-grid">line-grid</span> property</span></a></li>
<li><a href="#grid-snapping"><span class="secno">3</span> <span class="content">
Snapping to a Grid</span></a>
<ul class="toc">
<li><a href="#line-snap"><span class="secno">3.1</span> <span class="content">
Snapping Line Boxes: the <span class="property" data-link-type="propdesc" title="line-snap">line-snap</span> property</span></a></li>
<li><a href="#box-snap"><span class="secno">3.2</span> <span class="content">
Snapping Block Boxes: the <span class="property" data-link-type="propdesc" title="box-snap">box-snap</span> property</span></a></li>
</ul>
</li>
<li><a href="#snap-details"><span class="secno">4</span> <span class="content">
Snapping Details</span></a>
<ul class="toc">
<li><a href="#alignment-interactions"><span class="secno">4.1</span> <span class="content">
Interacting with other alignments</span></a></li>
<li><a href="#leading-adjustments"><span class="secno">4.2</span> <span class="content">
Leading adjustments</span></a></li>
</ul>
</li>
<li><a href="#acknowledgments"><span class="secno"></span> <span class="content">Acknowledgments</span></a></li>
<li><a href="#change-log"><span class="secno"></span> <span class="content">
Change Log</span></a>
<ul class="toc">
<li><a href="#20140916"><span class="secno"></span> <span class="content">
Since <span>September 16th 2014</span></span></a></li>
<li><a href="#20140403"><span class="secno"></span> <span class="content">
Since <span>April 3rd 2014</span></span></a></li>
</ul>
</li>
<li><a href="#conformance"><span class="secno"></span> <span class="content">
Conformance</span></a>
<ul class="toc">
<li><a href="#conventions"><span class="secno"></span> <span class="content">
Document conventions</span></a></li>
<li><a href="#conformance-classes"><span class="secno"></span> <span class="content">
Conformance classes</span></a></li>
<li><a href="#partial"><span class="secno"></span> <span class="content">
Partial implementations</span></a></li>
<li><a href="#experimental"><span class="secno"></span> <span class="content">
Experimental implementations</span></a></li>
<li><a href="#testing"><span class="secno"></span> <span class="content">
Non-experimental implementations</span></a></li>
</ul>
</li>
<li><a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a></li>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a></li>
</ul>
</li>
<li><a href="#index"><span class="secno"></span> <span class="content">Index</span></a></li>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a></li>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a></li>
</ul></div>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">
Introduction</span><a class="self-link" href="#intro"></a></h2>
<h3 class="heading settled" data-level="1.1" id="context"><span class="secno">1.1. </span><span class="content">
Background</span><a class="self-link" href="#context"></a></h3>
<p><em>This section is not normative.</em></p>
<p>This specification provides features
to align lines and blocks
to invisible grids in the document.</p>
<p>Aligning lines and blocks to grids
provides the following benefits:</p>
<ul>
<li>Vertical rhythm is kept for better readability.</li>
<li>Lines are aligned between columns in multi-column documents.</li>
<li>The top and the bottom margins of pictures are made equal,
while keeping the vertical rhythm of text before and after the pictures.</li>
<li>Layout lines are at the same position on every page in paged media.
Keeping the position of the bottom line of a page has benefits for
design and readability.
This also improves the readability of duplex printing,
two pages spreads,
and displaying on slow display devices like e-ink.</li>
<li>East Asian layouts require vertical rhythm
more often than other scripts do,
even in single column, non-paged media documents,
as defined in <a data-biblio-type="informative" data-link-type="biblio" href="#biblio-jlreq" title="JLREQ">[JLREQ]</a>.</li>
</ul>
<p>There are several types of objects in a document
that can break the vertical rhythm.
Examples include lines with different sizes of text,
pictures, and tables.</p>
<div class="figure">
<img alt="Vertical rhythm kept through pictures and different size of text in a multi-column document" src="images/line-grid-multicol.png" width="480">
<p class="caption">Vertical rhythm kept through pictures and different size of text in a multi-column document.</p>
</div>
<div class="example">
<div class="sidefigure">
<img alt="Large text wraps within line grids" src="images/line-grid-wrap.png" width="276">
<p class="caption">Large text wraps within line grids.</p>
</div>
<p>When a different size of text,
such as a headings wraps,
it is usually aligned to grids as a block
and the lines within the block do not align.</p>
<p><br style="clear:both;"></p>
</div>
<div class="figure" id="ex-sidenote">
<div class="sidenote-block">
<div class="sidenote-body">
<p>Sidenotes (and footnotes for that matter) are often set
at a smaller size than the basic text.
This smaller text should still line up with the basic text.
Authors can try to achieve this effect
by calculating appropriate font-size, line-height,
and margins*, but lack the proper tools to get the baselines to align.</p>
</div>
<div class="sidenote-note">
<p>Even if the author controls all this,
the baselines won’t align. And careful
calculations can be thrown off by user stylesheets.</p>
</div>
</div>
<p class="caption">Sidenotes are set at a smaller size, and baselines don’t align.</p>
</div>
<figure>
<img alt="sidenote rendering with aligned baselines" src="images/sidenote-aligned.png">
<figcaption>
Sidenote with baselines aligned to the body text.
</figcaption>
</figure>
<div class="sidefigure" id="ex-width">
<img alt="East Asian layouts may require width be a multiple of em without fractions" height="142" src="width-multiple-of-em.png" width="180">
<p class="caption">East Asian layouts may require width
be a multiple of <em>em</em> without fractions.</p>
</div>
<p>East Asian layouts may require grid-like features
in inline progression direction as well.</p>
<p>It is often desirable in East Asian layouts
to make the line width
a multiple of <em>em</em> without fractions.
Because most East Asian characters have 1em advance
and most East Asian documents are justified,
this minimizes cases where justification needs to expand character spacing.</p>
<p>This module provides the following capabilities:</p>
<ul>
<li>Defining grids in the line progression direction.</li>
<li>Controlling how lines and blocks align to the grids.</li>
</ul>
<p>It is important to control these capabilities independently,
so that, for example,
aligning to grids can be turned off for tables,
but can then be turned back on
for aligning the following text to the grids.</p>
<h3 class="heading settled" data-level="1.2" id="placement"><span class="secno">1.2. </span><span class="content">
Module Interactions</span><a class="self-link" href="#placement"></a></h3>
<p>This module extends the line box model
defined in <a data-biblio-type="normative" data-link-type="biblio" href="#biblio-css21" title="CSS21">[CSS21]</a> sections 9.4.2 and 10.8.</p>
<h3 class="heading settled" data-level="1.3" id="values"><span class="secno">1.3. </span><span class="content">
Values</span><a class="self-link" href="#values"></a></h3>
<p>This specification follows the
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">
CSS property definition conventions
</a>
from <a data-biblio-type="normative" data-link-type="biblio" href="#biblio-css21" title="CSS21">[CSS21]</a>.
Value types not defined in this specification
are defined in CSS Level 2 Revision 1 <a data-biblio-type="normative" data-link-type="biblio" href="#biblio-css21" title="CSS21">[CSS21]</a>.
Other CSS modules may expand
the definitions of these value types:
for example <a data-biblio-type="informative" data-link-type="biblio" href="#biblio-css3color" title="CSS3COLOR">[CSS3COLOR]</a>,
when combined with this module,
expands the definition
of the <color> value type
as used in this specification.</p>
<p>In addition to the property-specific values
listed in their definitions,
all properties defined in this specification
also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value.
For readability it has not been repeated explicitly.</p>
<h2 class="heading settled" data-level="2" id="line-grid-property"><span class="secno">2. </span><span class="content">
Defining a <dfn data-dfn-type="dfn" data-noexport="" id="line-grid">Line Grid<a class="self-link" href="#line-grid"></a></dfn>: the <a class="property" data-link-type="propdesc" href="#propdef-line-grid">line-grid</a> property</span><a class="self-link" href="#line-grid-property"></a></h2>
<table class="definition propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-line-grid">line-grid<a class="self-link" href="#propdef-line-grid"></a></dfn></td>
</tr>
<tr>
<th>Value:</th>
<td class="prod">match-parent <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> create</td>
</tr>
<tr>
<th>Initial:</th>
<td>match-parent</td>
</tr>
<tr>
<th>Applies to:</th>
<td>block, flex and grid containers</td>
</tr>
<tr>
<th>Inherited:</th>
<td>no</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th>Animatable:</th>
<td>no</td>
</tr>
</tbody></table>
<p>Specifies whether this box creates
a new baseline grid for its descendants
or uses the same baseline grid as its parent.
(Each box always has an associated <a data-link-type="dfn" href="#line-grid">line grid</a>.
However, whether a box or its contents snap
to a <a data-link-type="dfn" href="#line-grid">line grid</a> is determined
by <a class="property" data-link-type="propdesc" href="#propdef-line-snap">line-snap</a> and <a class="property" data-link-type="propdesc" href="#propdef-box-snap">box-snap</a>.)</p>
<p>The values of this property have the following meanings:</p>
<dl data-dfn-for="line-grid" data-dfn-type="value">
<dt><dfn class="css" data-dfn-for="line-grid" data-dfn-type="value" data-export="" id="valdef-line-grid-match-parent">match-parent<a class="self-link" href="#valdef-line-grid-match-parent"></a></dfn>
</dt>
<dd>Box assumes the <a data-link-type="dfn" href="#line-grid">line grid</a> of its parent.
</dd>
<dt><dfn class="css" data-dfn-for="line-grid" data-dfn-type="value" data-export="" id="valdef-line-grid-create">create<a class="self-link" href="#valdef-line-grid-create"></a></dfn>
</dt>
<dd>Box creates a new <a data-link-type="dfn" href="#line-grid">line grid</a>
using its own font and line layout settings.
The <a data-link-type="dfn" href="#line-grid">line grid</a> consists of a series
of horizontal lines corresponding
to all the baselines
(alphabetic, text-top, text-bottom,
mathematic, central, hanging, etc.)
and to the line-over and line-under edges,
positioned where they would fall
if the contents of this element consisted entirely
of line boxes filled with text (no sub-elements)
using the first available font.
If the box is paginated,
the <a data-link-type="dfn" href="#line-grid">line grid</a> is restarted on each page;
since line boxes cannot be fragmented,
no page begins with the bottom part of a line’s grid.
</dd>
</dl>
<p>The initial containing block establishes a <a data-link-type="dfn" href="#line-grid">line grid</a>
using the font and line layout settings of the root element.
If the root element (which has no parent)
has a value of <a class="css" data-link-type="maybe" href="#valdef-line-grid-match-parent">match-parent</a>,
then it adopts the <a data-link-type="dfn" href="#line-grid">line grid</a> of the initial containing block.</p>
<p>In paged media,
if the page context applying to a particular page
specifies <a class="css" data-link-type="propdesc" href="#propdef-line-grid" title="line-grid">line-grid: create</a>,
then a <a data-link-type="dfn" href="#line-grid">line grid</a> for that page is established
using the page context’s font and line layout settings
applied to the page box (including its margins),
and for layout within that page the initial containing block
is assumed to have adopted this <a data-link-type="dfn" href="#line-grid">line grid</a>.</p>
<div class="example">
Since the initial value of <a class="property" data-link-type="propdesc" href="#propdef-line-grid">line-grid</a> is <a class="css" data-link-type="maybe" href="#valdef-line-grid-match-parent">match-parent</a>,
by default a <a data-link-type="dfn" href="#line-grid">line grid</a> is automatically created
using the root element’s font and line height settings
to fill the initial containing block / page area.
When all pages of a document are the same size,
this will result in a consistent <a data-link-type="dfn" href="#line-grid">line grid</a> that exactly aligns
to the top of each page area.
<p>It is sometimes appropriate
for the <a data-link-type="dfn" href="#line-grid">line grid</a> to begin with the content,
after the root element’s margins/padding/border
and/or other header content.
To do this, the root element (or some other element) can be told to establish the <a data-link-type="dfn" href="#line-grid">line grid</a>.</p>
<pre>main { line-grid: create; }
</pre>
<p>If this <a data-link-type="dfn" href="#line-grid">line grid</a> is then paginated, the <a data-link-type="dfn" href="#line-grid">line grid</a> will start at the top of each page area after the first.</p>
<p>In other cases, it’s desirable for
all pages of a document share a common <a data-link-type="dfn" href="#line-grid">line grid</a>,
even if page margins, border and/or padding change.
The following rule will instead fill the page box area
<em>including</em> the page margin/padding/borders
with the <a data-link-type="dfn" href="#line-grid">line grid</a>:</p>
<pre>@page { line-grid: create; }
</pre>
<p>As this <a data-link-type="dfn" href="#line-grid">line grid</a> is paginated, it will start at the top of each page box after the first;
however it might not align to the top of the page area
(where the content would normally begin).</p>
</div>
<p class="issue" id="issue-68d02fb3"><a class="self-link" href="#issue-68d02fb3"></a>The names of these values is currently up for debate.
Current suggestions for match-parent
include match-parent and normal;
those for create include create and new.</p>
<p class="note" role="note">The original proposal for line grids
allowed an element to create a named grid.
This property could still be extended to do this in the future.
</p>
<p class="note" role="note">There might need to be an offset
for more complicated designs.
How to set this offset is problematic:
usually it’s not a fixed length,
but the distance to clear some header content.
This could be added to a later level of css-line-grid.
</p>
<h2 class="heading settled" data-level="3" id="grid-snapping"><span class="secno">3. </span><span class="content">
Snapping to a Grid</span><a class="self-link" href="#grid-snapping"></a></h2>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-line-snap">line-snap</a> and <a class="property" data-link-type="propdesc" href="#propdef-box-snap">box-snap</a> properties
cause line boxes and block boxes to shift position
in order to align to the <a data-link-type="dfn" href="#line-grid">line grid</a>.
Shifting boxes in this way affects layout –
it is not merely a display translation.
If a line box is shifted,
then subsequent line boxes will be laid out
using the new shifted position as input
to their line stacking rules.
If a block box is shifted,
then subsequent boxes will be laid out
using the new shifted position as input.</p>
<h3 class="heading settled" data-level="3.1" id="line-snap"><span class="secno">3.1. </span><span class="content">
Snapping Line Boxes: the <a class="property" data-link-type="propdesc" href="#propdef-line-snap">line-snap</a> property</span><a class="self-link" href="#line-snap"></a></h3>
<table class="definition propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-line-snap">line-snap<a class="self-link" href="#propdef-line-snap"></a></dfn></td>
</tr>
<tr>
<th>Value:</th>
<td class="prod">none <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> baseline <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> contain</td>
</tr>
<tr>
<th>Initial:</th>
<td>none</td>
</tr>
<tr>
<th>Applies to:</th>
<td>all elements</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th>Animatable:</th>
<td>no</td>
</tr>
</tbody></table>
<p>This property applies to all the line boxes
directly contained by the element,
and, when not none,
causes each line box to shift
(usually downward, possibly by zero)
until it snaps to the <a data-link-type="dfn" href="#line-grid">line grid</a>
specified by <a class="property" data-link-type="propdesc" href="#propdef-line-grid">line-grid</a>.
(The unshifted position is the position that
would be determined by normal line stacking rules,
with consideration of any new controls
defined by other modules such as <a data-biblio-type="informative" data-link-type="biblio" href="#biblio-css3line" title="CSS3LINE">[CSS3LINE]</a>.)</p>
<p>Values have the following meanings:</p>
<dl data-dfn-for="line-snap" data-dfn-type="value">
<dt><dfn class="css" data-dfn-for="line-snap" data-dfn-type="value" data-export="" id="valdef-line-snap-none">none<a class="self-link" href="#valdef-line-snap-none"></a></dfn>
</dt>
<dd>Line boxes do not snap to the grid; they stack normally.
</dd>
<dt><dfn class="css" data-dfn-for="line-snap" data-dfn-type="value" data-export="" id="valdef-line-snap-baseline">baseline<a class="self-link" href="#valdef-line-snap-baseline"></a></dfn>
</dt>
<dd>The dominant baseline snaps with the matching baseline on the
<a data-link-type="dfn" href="#line-grid">line grid</a> applying to the element.
</dd>
<dt><dfn class="css" data-dfn-for="line-snap" data-dfn-type="value" data-export="" id="valdef-line-snap-contain">contain<a class="self-link" href="#valdef-line-snap-contain"></a></dfn>
</dt>
<dd>
Two baselines are used to align the line box:
the line box is snapped
so that its <a href="http://dev.w3.org/csswg/css-inline/#central">central</a> baseline
is centered between one
of the line grid’s <a href="http://dev.w3.org/csswg/css-inline/#text-over-edge">text-over-edge</a> baselines
and a subsequent (but not necessarily consecutive)
<a href="http://dev.w3.org/csswg/css-inline/#text-under-edge">text-under-edge</a> baseline.
</dd>
</dl>
<div class="example">
<p>Line boxes almost always shift downward
(towards the block-end direction)
when snapping to a <a data-link-type="dfn" href="#line-grid">line grid</a>.
Here there are three lines
with 20px line-height
and line-snap:baseline
that should snap to a 30px <a data-link-type="dfn" href="#line-grid">line grid</a>.
Each line box shifts down
so that the baselines align
with the grid lines.</p>
<figure style="float:left;">
<img alt="line positions before snapping" src="images/simple-no-snap.png">
<figcaption>
Before line snapping
</figcaption>
</figure>
<figure style="float:left;">
<img alt="line positions after snapping" src="images/simple-snapped.png">
<figcaption>
After line snapping
</figcaption>
</figure>
<p style="clear:left;">
In the figures below,
there are two additional lines
from h3 elements with line-snap:none.
These lines do not shift
to align to the grid,
but their positions can change
based on the shifting of lines around them.
In this example,
lines 1 2 and 3 shift down
to snap their baselines to the grid lines,
and line B has normal line box placement
just below the line above.
</p>
<figure style="float:left;">
<img alt="line positions before snapping" src="images/top-no-snap.png">
<figcaption>
Before line snapping
</figcaption>
</figure>
<figure style="float:left;">
<img alt="line positions after snapping" src="images/top-snapped.png">
<figcaption>
After line snapping
</figcaption>
</figure>
</div>
<h3 class="heading settled" data-level="3.2" id="box-snap"><span class="secno">3.2. </span><span class="content">
Snapping Block Boxes: the <a class="property" data-link-type="propdesc" href="#propdef-box-snap">box-snap</a> property</span><a class="self-link" href="#box-snap"></a></h3>
<p class="issue" id="issue-dcdebabc"><a class="self-link" href="#issue-dcdebabc"></a>This is a rough draft of trying to solve
the box-snapping problem.</p>
<p class="issue" id="issue-1bcf4d99"><a class="self-link" href="#issue-1bcf4d99"></a>Some optional box values
(margin-box, border-box)
could be added to the before and after values
to allow snapping various box model edges
to the <a data-link-type="dfn" href="#line-grid">line grid</a>.</p>
<p class="issue" id="issue-13c3b0a7"><a class="self-link" href="#issue-13c3b0a7"></a>An auto value could be useful -
one that defaults to center,
but snaps to before if it’s the first block in a fragment container,
and snaps to after if it’s the last block in a fragment container.</p>
<table class="definition propdef">
<tbody>
<tr>
<th>Name:</th>
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-box-snap">box-snap<a class="self-link" href="#propdef-box-snap"></a></dfn></td>
</tr>
<tr>
<th>Value:</th>
<td class="prod">none <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> block-start <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> block-end <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> center <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> baseline <a data-link-for="" data-link-type="grammar" href="http://dev.w3.org/csswg/css-values-3/#comb-one">|</a> last-baseline</td>
</tr>
<tr>
<th>Initial:</th>
<td>none</td>
</tr>
<tr>
<th>Applies to:</th>
<td>block-level boxes and internal table elements except table cells</td>
</tr>
<tr>
<th>Inherited:</th>
<td>yes</td>
</tr>
<tr>
<th>Percentages:</th>
<td>N/A</td>
</tr>
<tr>
<th>Media:</th>
<td>visual</td>
</tr>
<tr>
<th>Computed value:</th>
<td>as specified</td>
</tr>
<tr>
<th>Animatable:</th>
<td>no</td>
</tr>
</tbody></table>
<p>Specifies how the block is snapped to the baseline grid.</p>
<p>Values have the following meanings:</p>
<dl data-dfn-for="box-snap" data-dfn-type="value">
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-none">none<a class="self-link" href="#valdef-box-snap-none"></a></dfn>
</dt>
<dd>The block is not snapped to any grid.</dd>
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-block-start">block-start<a class="self-link" href="#valdef-box-snap-block-start"></a></dfn>
</dt>
<dd>The block-start edge is snapped to the nearest grid line.
</dd>
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-block-end">block-end<a class="self-link" href="#valdef-box-snap-block-end"></a></dfn>
</dt>
<dd>The block-end edge is snapped to the nearest grid line.
</dd>
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-center">center<a class="self-link" href="#valdef-box-snap-center"></a></dfn>
</dt>
<dd>The block is centered centered between
one of the baseline grid’s text-over baselines and a subsequent
(but not necessarily consecutive) text-under baseline.
</dd>
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-baseline">baseline<a class="self-link" href="#valdef-box-snap-baseline"></a></dfn>
</dt>
<dd>The first line box’s dominant baseline is snapped to the nearest grid line.
</dd>
<dt><dfn class="css" data-dfn-for="box-snap" data-dfn-type="value" data-export="" id="valdef-box-snap-last-baseline">last-baseline<a class="self-link" href="#valdef-box-snap-last-baseline"></a></dfn>
</dt>
<dd>The last line box’s dominant baseline is snapped to the nearest grid line.
</dd>
</dl>
<p>Snapping block boxes always uses the <a data-link-type="dfn" href="#line-grid">line grid</a> of the box parent
(a block’s own <a data-link-type="dfn" href="#line-grid">line grid</a> has no effect on box snapping).
If the box is an empty block that could be
<a href="http://www.w3.org/TR/CSS21/box.html">collapsed through</a>,
then this property has no effect. <a data-biblio-type="normative" data-link-type="biblio" href="#biblio-css21" title="CSS21">[CSS21]</a></p>
<p>To snap a block-level element to a grid line,
take the unsnapped result of layout
(including margin collapsing, clearance, etc.)
as the block’s initial position,
then shift the block downward
(towards the block-end direction)
until it snaps to the <a data-link-type="dfn" href="#line-grid">line grid</a>.</p>
<p>For the <a class="css" data-link-type="maybe" href="#valdef-box-snap-block-start">block-start</a> and <a class="css" data-link-type="maybe" href="#valdef-box-snap-block-end">block-end</a> values,
either the text-over-edge
or text-under-edge baseline is chosen:
whichever one is on the matching side
of the central baseline.
For example,
when snapping the block-start edge
in horizontal writing mode,
the text-over-edge is chosen.
In some cases the text-under-edge
might be used instead for the block-start edge:
for example,
when the writing mode of the <a data-link-type="dfn" href="#line-grid">line grid</a>
doesn’t match that of the affected element,
or when due to the <a class="property" data-link-type="propdesc" href="http://dev.w3.org/csswg/css-writing-modes-3/#propdef-text-orientation">text-orientation</a> settings
the text-under-edge corresponds to the block-start edge.</p>
<p>When applied to table row group and table row boxes,
<a class="property" data-link-type="propdesc" href="#propdef-box-snap">box-snap</a> only affects the before and after edges,
and only if those edges are not
at the beginning or end of the table, respectively.
To snap a before edge on a table row or row group,
the preceding row’s height is increased.
To snap an after edge on a table row or row group,
the affected row’s height is increased.</p>
<p>When applied to table column group and table column boxes,
'box-snap’only affects the start and end edges,
and only if those edges are not
at the start or end of the table, respectively.
How the space is redistributed among columns
to satisfy snapping constraints is not defined, however:</p>
<ul>
<li>In an auto-sized table no column may be smaller than its minimum content width.
</li>
<li>The resulting table must not exceed its original measure if it had a non-auto measure.
</li>
<li>The adjusted widths must not cause the table to overflow its containing block any more than it would with <a class="css" data-link-type="propdesc" href="#propdef-box-snap" title="box-snap">box-snap: none</a>.
</li>
</ul>