-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathdiff.html
1272 lines (1189 loc) · 84.3 KB
/
diff.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>
<base href="http://drafts.csswg.org/css-scroll-snap/">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Scroll Snapping Change Proposal</title>
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<meta content="exploring" name="csswg-work-status">
<meta content="UD" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="https://www.w3.org/StyleSheets/TR/2016/W3C-UD" rel="stylesheet" type="text/css">
<meta content="Bikeshed 1.0.0" name="generator">
<style type="text/css">
.delta {
position: relative;
display: inline !important;
line-height: 1;
border-radius: 50%;
padding: .1em 0.2em !important;
border: dotted 3px green !important;
text-decoration: none !important;
color: red !important;
font-weight: bold;
background: white;
}
.delta:not(.comment)::before {
content: "Δ";
}
.delta:focus,
.delta:hover {
box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}
.delta:active {
top: 1px; left: 1px;
}
ins, del {
color: inherit;
border-radius: 0.5em;
padding: 0 0.25em;
background: inherit;
}
ins { background: #AFA; }
del { background: #FBB; }
.move { background: #FF0; }
.up::after { content: "⇑"; }
.down::after { content: "⇓"; }
.block { display: block; }
</style>
<style type="text/css">
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #708090 } /* Comment */
.highlight .k { color: #990055 } /* Keyword */
.highlight .l { color: #000000 } /* Literal */
.highlight .n { color: #0077aa } /* Name */
.highlight .o { color: #999999 } /* Operator */
.highlight .p { color: #999999 } /* Punctuation */
.highlight .ch { color: #708090 } /* Comment.Hashbang */
.highlight .cm { color: #708090 } /* Comment.Multiline */
.highlight .cp { color: #708090 } /* Comment.Preproc */
.highlight .cpf { color: #708090 } /* Comment.PreprocFile */
.highlight .c1 { color: #708090 } /* Comment.Single */
.highlight .cs { color: #708090 } /* Comment.Special */
.highlight .kc { color: #990055 } /* Keyword.Constant */
.highlight .kd { color: #990055 } /* Keyword.Declaration */
.highlight .kn { color: #990055 } /* Keyword.Namespace */
.highlight .kp { color: #990055 } /* Keyword.Pseudo */
.highlight .kr { color: #990055 } /* Keyword.Reserved */
.highlight .kt { color: #990055 } /* Keyword.Type */
.highlight .ld { color: #000000 } /* Literal.Date */
.highlight .m { color: #000000 } /* Literal.Number */
.highlight .s { color: #a67f59 } /* Literal.String */
.highlight .na { color: #0077aa } /* Name.Attribute */
.highlight .nc { color: #0077aa } /* Name.Class */
.highlight .no { color: #0077aa } /* Name.Constant */
.highlight .nd { color: #0077aa } /* Name.Decorator */
.highlight .ni { color: #0077aa } /* Name.Entity */
.highlight .ne { color: #0077aa } /* Name.Exception */
.highlight .nf { color: #0077aa } /* Name.Function */
.highlight .nl { color: #0077aa } /* Name.Label */
.highlight .nn { color: #0077aa } /* Name.Namespace */
.highlight .py { color: #0077aa } /* Name.Property */
.highlight .nt { color: #669900 } /* Name.Tag */
.highlight .nv { color: #0077aa } /* Name.Variable */
.highlight .ow { color: #999999 } /* Operator.Word */
.highlight .mb { color: #000000 } /* Literal.Number.Bin */
.highlight .mf { color: #000000 } /* Literal.Number.Float */
.highlight .mh { color: #000000 } /* Literal.Number.Hex */
.highlight .mi { color: #000000 } /* Literal.Number.Integer */
.highlight .mo { color: #000000 } /* Literal.Number.Oct */
.highlight .sb { color: #a67f59 } /* Literal.String.Backtick */
.highlight .sc { color: #a67f59 } /* Literal.String.Char */
.highlight .sd { color: #a67f59 } /* Literal.String.Doc */
.highlight .s2 { color: #a67f59 } /* Literal.String.Double */
.highlight .se { color: #a67f59 } /* Literal.String.Escape */
.highlight .sh { color: #a67f59 } /* Literal.String.Heredoc */
.highlight .si { color: #a67f59 } /* Literal.String.Interpol */
.highlight .sx { color: #a67f59 } /* Literal.String.Other */
.highlight .sr { color: #a67f59 } /* Literal.String.Regex */
.highlight .s1 { color: #a67f59 } /* Literal.String.Single */
.highlight .ss { color: #a67f59 } /* Literal.String.Symbol */
.highlight .vc { color: #0077aa } /* Name.Variable.Class */
.highlight .vg { color: #0077aa } /* Name.Variable.Global */
.highlight .vi { color: #0077aa } /* Name.Variable.Instance */
.highlight .il { color: #000000 } /* Literal.Number.Integer.Long */
.highlight { background: hsl(24, 20%, 95%); }
code.highlight { padding: .1em; border-radius: .3em; }
pre.highlight, pre > code.highlight { display: block; padding: 1em; margin: .5em 0; overflow: auto; border-radius: 0; }</style>
<style type='text/css'>
<!-- a#bikeshed { width: 32px; height: 32px; display: block; position: fixed; right: 0; top: 0;
border-bottom-left-radius: 5px; background: #f4f4f4; box-shadow: 2px 0px 3px #444;
background-image: linear-gradient(to bottom, #eee, #fff 15%, #ededed 80%, #e0e0e0);
}
a#bikeshed:focus { outline: none;}
a#bikeshed svg { position: absolute; right: 3px; top: 3px; }
@keyframes fill {
0%, 100% { fill: blue; }
16% { fill: purple; }
33% { fill: hsl(0, 100%, 60%); }
50% { fill: orange; }
67% { fill: gold; }
83% { fill: hsl(120, 100%, 25%); }
}
@keyframes stroke {
0%, 100% { stroke: blue; }
16% { stroke: purple; }
33% { stroke: hsl(0, 100%, 60%); }
50% { stroke: orange; }
67% { stroke: gold; }
83% { stroke: hsl(120, 100%, 25%); }
}
a#bikeshed.fatal [fill=blue], a#bikeshed.error [fill=blue], .previous [fill=blue] { fill: #d00; }
a#bikeshed.fatal [stroke=blue], a#bikeshed.error [stroke=blue], .previous [stroke=blue] { stroke: #d00; }
a#bikeshed.warning [fill=blue] { fill: #0df; }
a#bikeshed.warning [stroke=blue] { stroke: #0df; }
a#bikeshed.link-error [fill=blue] { fill: #cc0; }
a#bikeshed.link-error [stroke=blue] { stroke: #cc0; }
a#bikeshed.success [fill=blue] { fill: #0b0; }
a#bikeshed.success [stroke=blue] { stroke: #0b0; }
a#bikeshed [fill=blue], [stroke=blue] { animation: n 5s infinite linear; transition: fill 1s, stroke 1s; }
a#bikeshed.pending [stroke=blue] { animation-name: stroke; }
a#bikeshed.pending [fill=blue] { animation-name: fill; }
a#bikeshed.generating [stroke=blue] { animation-name: stroke; }
a#bikeshed.generating [fill=blue] { animation-name: fill; } --></style></head>
<body class="h-entry">
<div class="head">
<p><a class="logo" href="http://www.w3.org/"><img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"></a>
<h1 class="p-name no-ref" id="title">
CSS Scroll Snap
<del>Points</del>
<a target="delta" class="delta" href="diff-notes#change-title">1</a>
Module Level 1
</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle">
Change Proposal Diff,
<time class="dt-updated" datetime="2016-04-06"> 6 April 2016</time>
</h2>
<div>
<dl>
<dt> This version:
<dd>
<del>https://drafts.csswg.org/css-snappoints/</del>
<ins>https://drafts.csswg.org/css-scroll-snap/</ins>
<a target="delta" class="delta" href="diff-notes#change-title">1</a>
<dt>Latest version:
<dd>http://www.w3.org/TR/css-snappoints-1/
<dt>Previous Versions:
<dd>http://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/
<dt>Feedback:
<dd>
<a href="mailto:www-style@w3.org?subject=%5Bcss-scroll-snap%5D%20YOUR%20TOPIC%20HERE"> www-style@w3.org</a> with subject line
“<kbd> <del>[css-snappoints]</del> <ins>[css-scroll-snap]</ins>
<a target="delta" class="delta" href="diff-notes#change-title">1</a>
<i> … message topic …</i></kbd> ”
(<a href="http://lists.w3.org/Archives/Public/www-style/" rel="discussion"> archives</a>)</span>
<dt>Issue Tracking:
<dd>In <a href="issues-2015-12">Disposition of Comments</a>
(see also <a href="issues-by-issue">previous Disposition of Comments</a>)
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard">
Matt Rakow (Microsoft)
<dd class="editor p-author h-card vcard">
<a class="p-name fn u-url url" href="http://xanthir.com/contact/">Tab Atkins-Bittner</a>
(<span class="p-org org">Google</span>)
<dd class="editor p-author h-card vcard">
Jacob Rossi (Microsoft)
<dd class="editor p-author h-card vcard">
<a class="p-name fn u-url url" href="http://fantasai.inkedblade.net/contact">Elika J. Etemad / fantasai</a>
(<span class="p-org org">Invited Expert)
</dl>
</div>
<p class="copyright">
<a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"> Copyright</a> © 2016 <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>). 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.
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract">
Abstract</h2>
<div class="p-summary">
<p>This module contains features to control panning and scrolling behavior with "snap positions".
<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">
Status of this document</h2>
<p>This is a diff as of 23 April 2016.
<nav id="toc">
<h2 class="no-num no-toc no-ref" id="contents">
Table of Contents </h2>
<ol class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> Introduction</a>
<li><a href="#use-cases"><span class="secno">2</span> Motivating Examples</a>
<li><a href="#definitions"><span class="secno">3</span> <del>Definitions</del></a>
<li><a href="#snap-model"><span class="secno">4</span> Overview</a>
<li><a href="#snap-container"><span class="secno">5</span> <ins>Capturing Scroll Snap Areas:</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a> Properties on the scroll container</a>
<ol class="toc">
<li><a href="#snap-type"><span class="secno">5.1</span> Scroll <del>Snap Types</del> <ins>Snapping Rules</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a>: the <span class="property"> scroll-snap-type</span> property</a>
<li><a href="#snap-padding"><span class="secno">5.2</span> Scroll <del>Snap Padding</del> <ins>Snapping Window</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a>: the <span class="property"> scroll-snap-padding</span> property</a>
</ol>
<li><a href="#element"><span class="secno">6</span> <ins>Aligning Scroll Snap Areas:</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a> Properties on the <del>elements</del> <ins>scrolling content</ins></a>
<ol class="toc">
<li><a href="#scroll-snap-areas"><span class="secno">6.1</span> Scroll <del>Snap</del> <ins>Snapping</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a> <del>Margin</del> <ins>Area</ins> <a target="delta" class="delta" href="diff-notes#change-margin-area">2</a>: the <span class="property"> scroll-snap-margin</span> property</a>
<li><a href="#scroll-snap-alignment"><span class="secno">6.2</span> Scroll <del>Snap</del> <ins>Snapping</ins> <a target="delta" class="delta" href="diff-notes#change-subheads">S</a> Alignment: the <span class="property"> scroll-snap-align</span> property</a>
<ol class="toc">
<li><a href="#snap-scope"><span class="secno"><ins>6.2.1</ins></span><span class="content"><ins> Scoping Valid Snap Positions to Visible Boxes</ins></span></a>
<li><a href="#snap-overflow"><span class="secno"><ins> 6.2.2</ins></span><span class="content"><ins> Snapping Boxes that Overflow the Scrollport</ins></span></a>
<li><a href="#unreachable"><span class="secno"><ins> 6.2.3</ins></span><span class="content"><ins> Unreachable Snap Areas</ins></span></a>
</ol>
<li><a href="#scroll-snap-stop"><span class="secno"><ins> 6.3</ins></span><ins> Scroll Snap Limits: the<span class="property"> scroll-snap-stop</span> property</ins></a>
</ol>
<li><a href="#snap"><span class="secno"><ins> 7</ins></span><span class="content"><ins> Snapping Mechanics</ins></span></a>
<ol class="toc">
<li><a href="#scroll-types"><span class="secno"><ins> 7.1</ins></span><span class="content"><ins> Types of Scrolling Methods</ins></span></a>
<li><a href="#snap-dimensions"><span class="secno"><ins> 7.2</ins></span><span class="content"><ins> Axis vs Point-Snapping</ins></span></a>
<li><a href="#choosing"><span class="secno"><ins> 7.3</ins></span><span class="content"><ins> Choosing Snap Positions</ins></span></a>
</ol>
<li><a href="#longhands">Appendix A: Longhands</a>
<ol class="toc">
<li><a href="#padding-longhands-physical">Physical Longhands for <span class="property"> scroll-snap-padding</span></a>
<li><a href="#padding-longhands-logical">Flow-relative Longhands for <span class="property"> scroll-snap-padding</span></a>
<li><a href="#area-longhands-physical">Physical Longhands for <span class="property"> scroll-snap-margin</span></a>
<li><a href="#area-longhands-logical">Flow-relative Longhands for <span class="property"> scroll-snap-margin</span></a>
</ol>
<li><a href="#priv-sec">Privacy and Security Considerations</a>
<li><a href="#acknowledgements">Acknowledgements</a>
</ol></nav>
<main>
<h2 class="heading settled" id="intro">
<span class="secno"> 1.</span> Introduction <a class="self-link" href="#intro"></a> </h2>
<p>[No proposed changes.]
<div>
<h2 class="heading settled" id="use-cases">
<span class="secno">
2.</span>
<span class="content">Motivating Examples
<a class="self-link" href="#use-cases"></a>
</h2>
<p>[ This collection of examples needs updating
to better showcase how scroll snap now works,
such as in cases where sizes of the content and/or viewport are variable. ]
<h2 class="heading settled" id="snap-model"><span class="secno">3.</span>
<span class="content">Overview</span><a class="self-link" href="#snap-model"></a></h2>
<p>This module introduces control over <dfn id="scroll-snap-position">scroll snap positions</dfn>,
which are scroll positions
that produce particular alignments of content
ithin a scrollable viewport.
Using the <a class="property" href="#propdef-scroll-snap-type">scroll-snap-type</a> property
n the relevant <a href="#scroll-container">scroll container</a>,
the author can request a particular bias for the viewport to land on a
<ins>valid</ins>
<a target="delta" class="delta" href="diff-notes#change-valid">V</a>
<a href="#scroll-snap-position">snap position</a>
after scrolling operations.
<p><a href="#scroll-snap-position">Snap positions</a> can be specified
as a particular alignment (<a class="property" href="#propdef-scroll-snap-align">scroll-snap-align</a>)
of an element’s <a href="#scroll-snap-area"><del>scroll snap margin</del> <ins>scroll snap area</ins></a>
<a target="delta" class="delta" href="diff-notes#change-scroll-snap-area">2</a>
(<del><a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a>, defaulting to its margin box</del>
<ins>its border bounding box, as modified by <a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a></ins>
<a target="delta" class="delta" href="diff-notes#change-margin-area">3</a>)
within the <a href="#scroll-container">scroll container</a>’s
<a href="#scroll-snap-viewport">snapport</a>
(<del>the rectangle obtained by reducing its visual viewport</del> <ins>its visual viewport, as reduced</ins>
by <del>its</del> <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a>
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>).
This is conceptually equivalent to specifying the alignment of an
<a href="https://drafts.csswg.org/css-align-3/#alignment-subject">alignment subject</a>
within an <a href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a>.
A scroll position that satisfies the specified alignment is a <ins>valid</ins> <a target="delta" class="delta" href="diff-notes#change-valid">V</a> <a href="#scroll-snap-position">snap position</a>.
<p><ins>The act of adjusting the scroll offset
of a scroll container’s visual viewport
such that it is aligned to a snap position
is called <dfn lt="snap">snapping</dfn>,
and a <a>scroll container</a> is said to be
<a>snapped</a> to a <a>snap position</a>
if its visual viewport’s scroll offset
is that <a>snap position</a>
and there is no active scrolling operation.</ins>
<a target="delta" class="delta" href="diff-notes#change-terms">D</a>
<ins class="move down">The CSS Scroll Snap Module
intentionally does not specify nor mandate
any precise animations or physics used to enforce <a>snap positions</a>;
this is left up to the user agent.</ins>
<a target="delta" class="delta" href="diff-notes#change-physics">4</a>
<p><a href="#scroll-snap-position">Snap positions</a> <del>must</del> only affect the nearest ancestor
<del class="move down">(on the element’s<a href="https://drafts.csswg.org/css-display-3/#containing-block-chain">containing block chain</a>)</del>
<a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>
<ins class="move up">on the element’s<a href="https://drafts.csswg.org/css-display-3/#containing-block-chain">containing block chain</a></ins>.
<a target="delta" class="delta" href="diff-notes#change-reword">R</a></p>
<del class="block">
<h2 class="heading settled" id="definitions"><span class="secno">4.</span> Definitions<a class="self-link" href="#definitions"></a>
<a target="delta" class="delta" href="diff-notes#change-terms">D</a></h2>
<dl>
<dt><dfn id="scroll-container">scroll container</dfn>
<dd> An element which provides a scrolling user interface as described in <a href="#biblio-css21">[CSS21]</a>, particularly in the section on overflow.
<dt><dfn id="snap-alignment-container">snap alignment container</dfn>
<dd>
A scroll container’s snap alignment container is the rectangle obtained by reducing its visual viewport by its <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a>.
<p class="issue" id="issue-1b6eda6b"><a class="self-link" href="#issue-1b6eda6b"></a> Better name for this concept?
<dt><dfn id="scroll-snap-margin">snap margin</dfn>
<dd> An element’s snap margin is the rectangle obtained by expanding its border box by its <a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a>.
<dt><dfn id="scroll-snap-position">snap position</dfn>
<dd> For a scroll container, a particular value for its scroll offset is a snap position if when scrolled to that offset the visual viewport of the scroll container would align with a descendent element in the manner specified by the scroll snap properties.
<dt><dfn id="scroll-snapped">snapped</dfn>
<dd> A scroll container is said to be snapped to a snap position if its visual viewport’s scroll offset is that snap position and there is no active scrolling operation.
<dt><dfn id="scroll-snap">snap</dfn>
<dd> The act of adjusting the scroll offset of a scroll container’s visual viewport such that it is snapped to a snap position is called snapping.
</dl>
</del>
<h2 class="heading settled" id="snap-container">
<span class="secno">5</span>
<ins>Capturing Scroll Snap Areas:</ins>
<a target="delta" class="delta" href="diff-notes#change-subhead">S</a>
Properties on the scroll container
<a class="self-link" href="#snap-container"></a>
</h2>
<h3 class="heading settled" id="snap-type"><span class="secno">5.1. </span><span class="content">Scroll Snap<ins>ping Rules</ins> <del>Types</del>:
<a target="delta" class="delta" href="diff-notes#change-subhead">S</a>
the <a class="property" href="#propdef-scroll-snap-type">scroll-snap-type</a> property</span><a class="self-link" href="#snap-type"></a></h3>
<table class="def propdef">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" id="propdef-scroll-snap-type">scroll-snap-type</dfn>
<tr class="value">
<th>Value:
<td class="prod">none <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <ins>[</ins> proximity <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> mandatory <ins>] <a href="https://drafts.csswg.org/css-values-3/#comb-any">||</a> [ x <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> y <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> block <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> inline <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> both <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> point ]</ins>
<a target="delta" class="delta" href="diff-notes#change-axes">5</a>
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td><a href="https://drafts.csswg.org/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Computed value:
<td>as specified
<tr>
<th>Animatable:
<td>no
</table>
<p>The <a class="property" href="#propdef-scroll-snap-type">scroll-snap-type</a> property <del>defines</del> <ins>specifies</ins>
<ins>whether a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> is a <a href="#scroll-snap-container">scroll snap container</a>,</ins>
<a target="delta" class="delta" href="diff-notes#change-trap">6</a>
how strictly <del>a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a></del> <ins>it</ins> <del>should</del> snap<del>s</del>,
<ins>and which axes are considered</ins> <a target="delta" class="delta" href="diff-notes#change-axes">5</a>.
<del class="move up">
It intentionally does not specify nor mandate
any precise animations or physics used in snapping;
this is left up to the user agent</del> <a target="delta" class="delta" href="diff-notes#change-physics">4</a>
<p class="issue" id="issue-cdf7fb7c"><a class="self-link" href="#issue-cdf7fb7c"></a> <a href="https://lists.w3.org/Archives/Public/www-style/2015Nov/0328.html">We’re considering splitting this into subproperties.</a> Current proposed names are <span class="css">scroll-snap</span> for the current grammar, <span class="css">scroll-snap-affinity</span> for the proximity/mandatory distinction,
and <span class="css">scroll-snap-axis</span> for the x/y/etc distinction.
<p><ins>The strictness values (<a class="css" href="#valdef-scroll-snap-type-none">none</a>, <a class="css" href="#valdef-scroll-snap-type-proximity">proximity</a>, <a class="css" href="#valdef-scroll-snap-type-mandatory">mandatory</a>) specify
how strictly <a href="#scroll-snap-position">snap positions</a> are enforced on the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> (by forcing an adjustment to the scroll offset).</ins> <a target="delta" class="delta" href="diff-notes#change-axes">5</a>
<ins>Values are defined as follows:</ins>
<dl>
<dt><dfn class="css" id="valdef-scroll-snap-type-none">none</dfn>
<dd>
<p><ins>If specified on a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,</ins>
<a target="delta" class="delta" href="diff-notes#change-trap">6</a>
the <a href="#scroll-container">scroll container</a>
must not <a href="#scroll-snap">snap</a>:
<ins>all scroll positions are equally valid</ins>.
<a target="delta" class="delta" href="diff-notes#change-clarify">C</a></p>
<ins class="block"><p>If specified on a non-<a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,
this value has no effect.
<a target="delta" class="delta" href="diff-notes#change-trap">6</a></p></ins>
<dt><dfn class="css" id="valdef-scroll-snap-type-proximity">proximity</dfn>
<dd>
<p><ins>If specified on a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,</ins>
<a target="delta" class="delta" href="diff-notes#change-trap">6</a>
the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>
may <a href="#snap">snap</a> <ins>to a valid <a href="#scroll-snap-position">snap position</a></ins><a target="delta" class="delta" href="diff-notes#change-clarify">C</a>
at the termination of a scroll<ins>,</ins>
at the discretion of the UA given the parameters of the scroll.</p>
<del class="block move down"><p>
If the content changes such that the scroll container would no longer be snapped (e.g. content is added, moved, deleted, resized) to the same snap position it was snapped to before the content change and that same snap position still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change.
<a target="delta" class="delta" href="diff-notes#change-resnap">9</a>
</p></del>
<ins class="block"><p>If specified on a non-<a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,
this value “traps” descendant boxes’ <a href="#scroll-snap-position">snap positions</a>,
preventing them from affecting any ancestor <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll containers</a>. <a target="delta" class="delta" href="diff-notes#change-trap">6</a></p></ins>
<dt><dfn class="css" id="valdef-scroll-snap-type-mandatory">mandatory</dfn>
<dd>
<ins>If specified on a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,</ins>
<a target="delta" class="delta" href="diff-notes#change-trap">6</a>
the scroll container is
<del>guaranteed</del> <ins>required</ins>
<a target="delta" class="delta" href="diff-notes#change-rfc2119">8</a>
to be snapped <ins>to a valid <a href="#scroll-snap-position">snap position</a></ins>
<a target="delta" class="delta" href="diff-notes#change-clarify">C</a>
when there are no active scrolling operations.
<del>If a reachable snap position exists, then the scroll container must snap at the termination of a scroll.</del>
<ins>That is, it must <a>snap</a> to a valid <a href="#scroll-snap-position">snap position</a> at the termination of a scroll, if any exist.</ins>
<ins>(</ins>If <del>no reachable snap position</del> <ins>none</ins> exist<del>s</del>, then no snapping occurs.<ins>)</ins>
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
<del class="block move down">
If the content changes such that the scroll container would no longer be snapped (e.g. content is added, moved, deleted, resized) to the same snap position it was snapped to before the content change, the scroll container must be re-snapped. If the same snap position it was snapped to before the content change still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change.
<a target="delta" class="delta" href="diff-notes#change-resnap">9</a>
</del>
<ins class="block"><p>If specified on a non-<a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>,
this value “traps” descendant boxes’ <a href="#scroll-snap-position">snap positions</a>,
preventing them from affecting any ancestor <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll containers</a>.
<a target="delta" class="delta" href="diff-notes#change-trap">6</a></p></ins>
</dl>
<ins class="block"><p>A box <dfn id="captures-snap-positions">captures snap positions</dfn> if it is a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> or has a value other than <a class="css" href="#valdef-scroll-snap-type-none">none</a> for <a class="property" href="#propdef-scroll-snap-type">scroll-snap-type</a>.
If a box’s nearest <a href="#captures-snap-positions">snap-position capturing</a> ancestor
on its <a href="https://drafts.csswg.org/css-display-3/#containing-block-chain">containing block chain</a> is a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> with a non-<a class="css" href="#valdef-scroll-snap-type-none">none</a> value for <a class="property" href="#propdef-scroll-snap-type">scroll-snap-type</a>,
that is the box’s <dfn id="scroll-snap-container">scroll snap container</dfn>.
Otherwise, the box has no <a href="#scroll-snap-container">scroll snap container</a>,
and its <a href="#scroll-snap-position">snap positions</a> do not trigger <a href="#snap">snapping</a>.
<a target="delta" class="delta" href="diff-notes#change-trap">6</a></p></ins>
<ins class="block"><p><strong class="advisement">Authors should use mandatory snap positions with consideration of
varyingly-sized screens and (if applicable) varying-sized content.
In particular, although access to snapped elements larger than the viewport
is <a href="#snap-overflow">handled by the UA</a>,
if authors assign mandatory snapping to non-adjacent siblings,
content in between can become inaccessible
in cases where it is longer than the screen.</strong>
<a target="delta" class="delta" href="diff-notes#change-warn">7</a></p></ins>
<div class="example" id="example-0740e5d8">
<a class="self-link" href="#example-0740e5d8"></a> For example, if an author wishes to force snapping to the top of each section heading,
s/he could accomplish this in two ways: snapping the headings
<pre>h1, h2, h3, h4, h5, h6 { scroll-snap-align: start; } /* snap headings - but not section content */</pre>
<p>or snapping the section elements.
<pre>section { scroll-snap-align: start; } /* snap entire section - including content */</pre>
<p>If the author chooses mandatory snapping of the headings,
and one section is longer than the viewport,
then the reader will have difficulty accessing the content that overflows the screen,
because mandatory snapping does not allow the scroll position to rest
on the content between the snapped headings.
<p>However, if the author chooses mandatory snapping of the section element
(which contains all the content of the section)
then the UA can allow the reader to scroll freely through the entire section
in the cases where the content is longer than the screen.
</div>
<ins class="block">
<p>The axis values specify what axis(es) are affected by <a href="#scroll-snap-position">snap positions</a>,
and whether <a href="#scroll-snap-position">snap positions</a> are evaluated independently per axis,
or together as a 2D point.
Values are defined as follows:
<dl>
<dt><dfn class="css" id="valdef-scroll-snap-type-x">x<a class="self-link" href="#valdef-scroll-snap-type-x"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#axis-snapping">axis-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in its horizontal axis only.
<dt><dfn class="css" id="valdef-scroll-snap-type-y">y<a class="self-link" href="#valdef-scroll-snap-type-y"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#axis-snapping">axis-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in its vertical axis only.
<dt><dfn class="css" id="valdef-scroll-snap-type-block">block<a class="self-link" href="#valdef-scroll-snap-type-block"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#axis-snapping">axis-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in its block axis only.
<dt><dfn class="css" id="valdef-scroll-snap-type-inline">inline<a class="self-link" href="#valdef-scroll-snap-type-inline"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#axis-snapping">axis-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in its inline axis only.
<dt><dfn class="css" id="valdef-scroll-snap-type-both">both<a class="self-link" href="#valdef-scroll-snap-type-both"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#axis-snapping">axis-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in both of its axises independently
(potentially snapping to different elements in each axis).
<dt><dfn class="css" id="valdef-scroll-snap-type-point">point<a class="self-link" href="#valdef-scroll-snap-type-point"></a></dfn>
<dd> The <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> <a href="#point-snapping">point-snaps</a> to <a href="#scroll-snap-position">snap positions</a> in both axises simultaneously,
treating each element’s <a href="#scroll-snap-position">snap position</a> as a single 2D position
(rather than potentially snapping to different elements in each axis).
</dl>
<p>If no axis value is specified, then the axis is automatically computed:
<ul>
<li><p>If the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> is only scrollable in one axis
(only one axis has its <a class="property" href="https://drafts.csswg.org/css-overflow-4/#propdef-overflow">overflow</a> set to <a class="css" href="https://drafts.csswg.org/css-overflow-4/#valdef-overflow-auto">auto</a> or <a class="css" href="https://drafts.csswg.org/css-overflow-4/#valdef-overflow-scroll">scroll</a>)
it <a href="#axis-snapping">axis-snaps</a> in the scrollable axis only.
<li><p>Otherwise, it <a href="#axis-snapping">axis-snaps</a> in its <a href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a> only.
</ul>
<p><a target="delta" class="delta" href="diff-notes#change-axes">5</a></p>
</ins>
<ins class="block move">
<a target="delta" class="delta" href="diff-notes#change-resnap">9</a>
<p>If the content <ins>or layout of the scroll container</ins> changes
e.g. content is added, moved, deleted, resized),
<ins>the UA must re-evaluate, and potentially re-snap if necessary, the resulting scroll offset once the positions of the content have restabilized</ins>.
<ins>This can result in no snapping, (e.g. if there are no nearby snap positions for a proximitiy-snapping scroll container).</ins>
<ins>However, if there was a previously-snapped snap position (associated with the same element) that still exists after such changes, the UA must remain snapped to it</ins>—<ins>even if the changes would have placed a different snap position closer to the current scroll offset</ins> <a target="delta" class="delta" href="diff-notes#change-clarify">C</a>.
<ins>Otherwise, the scroll container must be re-snapped as if the user had scrolled to its current scroll offset (as an explicit scroll, if no other scroll operation is active).</ins></p>
<p>… <del>changes such that the scroll container would no longer be <a data-link-type="dfn" href="#scroll-snapped" id="ref-for-scroll-snapped-3">snapped</a></del> (e.g. content is added, moved, deleted, resized) <del>to the same snap position it was snapped to before the content change and that same snap position still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change.</del></p>
<p>… <del>changes such that the scroll container would no longer be snapped</del> (e.g. content is added, moved, deleted, resized) <del>to the same snap position it was snapped to before the content change, the scroll container must be re-snapped. If the same snap position it was snapped to before the content change still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change.</del></p>
</ins>
<h3 class="heading settled" id="snap-padding"><span class="secno">5.2.</span>
Scroll <del>Snap Padding</del> <ins>Snapping Window</ins> <a target="delta" class="delta" href="diff-notes#change-subhead">S</a>:
he <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a> property</span><a class="self-link" href="#snap-padding"></a></h3>
<table class="def propdef">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" id="propdef-scroll-snap-padding">scroll-snap-padding</dfn>
<tr class="value">
<th>Value:
<td class="prod">[ <a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title="Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a> <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" href="https://drafts.csswg.org/css-values-3/#percentage-value"><percentage></a> ]<a href="https://drafts.csswg.org/css-values-3/#mult-num-range">{1,4}</a>
<tr>
<th>Initial:
<td>0
<tr>
<th>Applies to:
<td><a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll containers</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>relative to <ins>the corresponding dimension of</ins>
<a target="delta" class="delta" href="diff-notes#change-relxy">8</a>
the scroll container’s visual viewport
<tr>
<th>Computed value:
<td>as specified, with lengths made absolute
<tr>
<th>Animatable:
<td><del>yes</del> <ins>as length, percentage, or calc</ins>
<a target="delta" class="delta" href="diff-notes#change-animatable">9</a>
</table>
<p>The <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a> property defines the <dfn id="scroll-snapport">scroll snapport</dfn>—<!--
--><del>a region inset from the visual viewport of a <a href="#scroll-container">scroll container</a> used in calculating its <a href="#scroll-snap-position">snap positions</a>. The snapport is used as the alignment container when calculating <a href="#scroll-snap-position">snap positions</a>.</del>
<ins>the area of the scrollport that is used as the <a href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a> of the <a href="#scroll-snap-area">scroll snap areas</a> when calculating their <a href="#scroll-snap-position">snap positions</a></ins>.
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
<dl>
<dt><del><dfn class="css" id="valdef-scroll-snap-padding--length--percentage-1-4">[ <a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title="Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a> | <a class="production css" href="https://drafts.csswg.org/css-values-3/#percentage-value"><percentage></a> ]{1,4}<a class="self-link" href="#valdef-scroll-snap-padding--length--percentage-1-4"></a></dfn></del>
<dd><del>Specifies the region inset from the visual viewport.</del> <a target="delta" class="delta" href="diff-notes#change-reword">R</a> Values are interpreted as for <a class="property" href="https://drafts.csswg.org/css2/box.html#propdef-padding">padding</a>, and specify inward offsets from each edge of the visual viewport.
</dl>
<p>This property is a <a href="https://drafts.csswg.org/css-cascade-4/#shorthand-property">shorthand property</a> that sets
all of the <a href="#longhands"><span class="css">scroll-snap-padding-*</span> longhands</a> in one declaration.
<h2 class="heading settled" id="element"><span class="secno">6.</span>
<ins>Aligning Scroll Snap Areas:</ins>
Properties on the <del>elements</del> <ins>scrolling content</ins><a class="self-link" href="#element"></a></h2>
<h3 class="heading settled" id="scroll-snap-areas"><span class="secno">6.1.</span>
Scroll <del>Snap Margin</del> <ins>Snapping Area</ins> <a target="delta" class="delta" href="diff-notes#change-subhead">S</a>:
the <a class="property" href="#propdef scroll-snap-margin">scroll-snap-margin</a> property</span><a class="self-link" href="#scroll-snap-areas"></a></h3>
<table class="def propdef">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" id="propdef-scroll-snap-margin">scroll-snap-margin</dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title="Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a><a href="https://drafts.csswg.org/css-values-3/#mult-num-range">{1,4}</a>
<tr>
<th>Initial:
<td>0
<tr>
<th>Applies to:
<td><a href="https://drafts.csswg.org/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Computed value:
<td>as specified, with lengths made absolute
<tr>
<th>Animatable:
<td><del>yes</del> <ins>as length</ins>
</table>
<p>The <a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a> property
defines the <dfn id="scroll-snap-area">scroll snap <del>margin</del> <ins>area</ins>
<a target="delta" class="delta" href="diff-notes#change-margin-area">2</a></dfn>
<del>on elements within a <a href="#scroll-container">scroll container</a>, used in calculating <a href="#scroll-snap-position">snap positions</a> for that scroll container</del>
<ins>that is used for snapping this box to the <a href="#scroll-snapport">snapport</a></ins>.
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
<ins>The <a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title= "Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a> values give outsets (interpreted as for <a class="property" href="https://drafts.csswg.org/css2/box.html#propdef-margin">margin</a> or <a class="property" href="https://drafts.csswg.org/css-backgrounds-3/#border-image-outset">border-image-outset</a>).
The <a href="#scroll-snap-area">scroll snap area</a> is the rectangular bounding box of the transformed border box, plus the specified outsets, axis-aligned in the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container’s</a> coordinate space.</ins>
<a target="delta" class="delta" href="diff-notes#change-length-14">12</a></p>
<del class="block">
<dl>
<dt><dfn class="css" id="valdef-scroll-snap-margin-length1-4"><a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title="Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a>{1,4}<a class="self-link" href="#valdef-scroll-snap-margin-length1-4"></a></dfn>
<dd>
Specifies the outset of the element’s snap margin from the axis-aligned bounding box of the transformed border box, in the <a href="#scroll-container">scroll container’s</a> coordinate space. Outsets are applied to this bounding box, not the border box.
</dl>
</del>
<p class="note" role="note">Note: This ensures that the <a href="#scroll-snap-area">scroll snap <del>margin</del> <ins>area</ins></a> <a target="delta" class="delta" href="diff-notes#change-margin-area">2</a>
is always rectangular and axis-aligned to the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container’s</a> coordinate space.
<p>This property is a <a href="https://drafts.csswg.org/css-cascade-4/#shorthand-property">shorthand property</a> that sets all of the <a href="#longhands"><span class="css">scroll-snap-margin-*</span> longhands</a> in one declaration.
<h3 class="heading settled" id="scroll-snap-alignment"><span class="secno">6.2.</span>
Scroll <del>Snap</del> <ins>Snapping</ins> Alignment <a target="delta" class="delta" href="diff-notes#change-subhead">S</a>:
the <a class="property" href="#propdef-scroll-snap-align">scroll-snap-align</a> property <a class="self-link" href="#scroll-snap-alignment"></a></h3>
<table class="def propdef">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" id="propdef-scroll-snap-align">scroll-snap-align</dfn>
<tr class="value">
<th>Value:
<td class="prod">[ none <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> start <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> end <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> center ]<a href="https://drafts.csswg.org/css-values-3/#mult-num-range">{1,2}</a>
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td><a href="https://drafts.csswg.org/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Computed value:
<td>two keywords
<tr>
<th>Animatable:
<td>no
</table>
<p>The <a class="property" href="#propdef-scroll-snap-align">scroll-snap-align</a> property specifies
<del>how an element’s scroll snap margin should align with its ancestor scroll container’s snapport</del>
<ins>the box’s <a data-link-type="dfn" href="#scroll-snap-position">snap position</a>
as an alignment of its <a data-link-type="dfn" href="#scroll-snap-area">snap area</a>
(as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-subject">alignment subject</a>)
within its <a data-link-type="dfn" href="#scroll-snap-container">snap container’s</a> <a data-link-type="dfn" href="#scroll-snapport">snapport</a>
as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a>)</ins>.
<a target="delta" class="delta" href="diff-notes#change-alignment">13</a>
The two values specify the snapping behavior in the <del>x</del> <ins>block</ins> and <del>y</del> <ins>inline</ins> axes, respectively. If only one value is specified, the second value defaults to the same value.</p>
<p><ins>Values are defined as follows:</ins>
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
<dl>
<dt><dfn class="css" id="valdef-scroll-snap-align-none">none<a class="self-link" href="#valdef-scroll-snap-align-none"></a></dfn>
<dd>This box does not define a <a href="#scroll-snap-position">snap position</a> in the specified axis.
<dt><dfn class="css" id="valdef-scroll-snap-align-start">start<a class="self-link" href="#valdef-scroll-snap-align-start"></a></dfn>
<dd><del class="block">The scroll offset which aligns the start edge of this box’s scroll snap margin with the start edge of its ancestor scroll container’s region defined by <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a> in the specified axis is a <a href="#scroll-snap-position">snap position</a> in that axis.</del>
<dd><ins class="block">Start alignment of this box’s <a href="#scroll-snap-area">scroll snap area</a> within the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>’s <a href="#scroll-snapport">snapport</a> is a valid <a href="#scroll-snap-position">snap position</a> in the specified axis.</ins>
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
<dt><dfn class="css" id="valdef-scroll-snap-align-end">end<a class="self-link" href="#valdef-scroll-snap-align-end"></a></dfn>
<dd><del class="block">The scroll offset which aligns the end edge of this box’s scroll snap margin with the end edge of its ancestor scroll container’s region defined by <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a> in the specified axis is a <a href="#scroll-snap-position">snap position</a> in that axis.</del>
<dd><ins class="block">End alignment of this box’s <a href="#scroll-snap-area">scroll snap area</a> within the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>’s <a href="#scroll-snapport">snapport</a> is a valid <a href="#scroll-snap-position">snap position</a> in the specified axis.</ins>
<a target="delta" class="delta" href="diff-notes#change-eword">R</a>
<dt><dfn class="css" id="valdef-scroll-snap-align-center">center<a class="self-link" href="#valdef-scroll-snap-align-center"></a></dfn>
<dd><del class="block">The scroll offset which aligns the center of this box’s scroll snap margin with the center of its ancestor scroll container’s region defined by <a class="property" href="#propdef-scroll-snap-padding">scroll-snap-padding</a> in the specified axis is a <a href="#scroll-snap-position">snap position</a> in that axis.</del>
<dd><ins class="block">Center alignment of this box’s <a href="#scroll-snap-area">scroll snap area</a> within the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>’s <a href="#scroll-snapport">snapport</a> is a valid <a href="#scroll-snap-position">snap position</a> in the specified axis.</ins>
<a target="delta" class="delta" href="diff-notes#change-reword">R</a>
</dl>
<ins class="block">
<p>If the element’s <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> is <a href="#point-snapping">point-snapping</a>,
and this property does not specify a valid <a href="#scroll-snap-position">snap position</a> in both axises
(that is, it contains <a class="css" href="#valdef-scroll-snap-align-none">none</a>),
the element does not contribute any <a href="#scroll-snap-position">snap positions</a> at all.</p>
<a target="delta" class="delta" href="diff-notes#change-point">15</a>
</ins>
<ins class="block">
<p>For all of these values,
the <a href="https://drafts.csswg.org/css-display-3/#block">block</a> or <a href="https://drafts.csswg.org/css-display-3/#inline">inline</a> axis
is relative to the element’s parent’s <a href="https://drafts.csswg.org/css-writing-modes-3/#writing-mode">writing mode</a>.
<a target="delta" class="delta" href="diff-notes#change-align-axes">14</a>
<p class="issue" id="issue-eb80fe83"><a class="self-link" href="#issue-eb80fe83"></a> Is this the correct writing mode to compute against?
Or should it be the scroll container’s writing mode?</p>
</ins>
<ins class="block">
<details class="note" role="note">
<summary>Why no <a class="production css" href="https://drafts.csswg.org/css-values-3/#length-value" title="Expands to: em | advance measure | ch | vmin | cm | pc | pixel unit | in | rem | q | vh | ex | pt | vw | vmax | mm"><length></a> or <a class="production css" href="https://drafts.csswg.org/css-backgrounds-3/#position"><position></a> values?</summary>
<p>The values here represent alignments
(in the sense of <a class="property" href="https://drafts.csswg.org/css-align-3/#propdef-align-self">align-self</a> and <a class="property" href="https://drafts.csswg.org/css-align-3/#propdef-justify-self">justify-self</a>),
so are consistent with that syntax.
We chose to use this simpler syntax without lengths or percentages
because the <a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a> concept already provides length offsets—<wbr>but does so in a smarter way, that degrades better on small screens (see above)
because it provides more information (a box, rather than a point) to the UA.
We could have also added lengths here,
but it would provide multiple ways to do the same thing,
which is additional overhead for implementation, testing, and (most importantly) author learning.
It also introduces more room for cascading errors,
and guides authors in the wrong direction—<wbr>away from <a class="property" href="#propdef-scroll-snap-margin">scroll-snap-margin</a>.</p>
</details>
</ins>
<ins class="block">
<h4 class="heading settled" id="snap-scope"><span class="secno">6.2.1. </span><span class="content"> Scoping Valid Snap Positions to Visible Boxes</span><a class="self-link" href="#snap-scope"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-62">I-62</a></h4>
<p>Since the purpose of scroll snapping is to align content within the viewport
for optimal viewing:
in all cases, the specified alignment creates a valid <a href="#scroll-snap-position">snap position</a> only if at least part of the <a href="#scroll-snap-area">snap area</a> is within the <a href="#scroll-snapport">snapport</a>.
For example, a <a href="#scroll-snap-area">snap area</a> is top-aligned to the <a href="#scroll-snapport">snapport</a> if its top edge is coincident with the <a href="#scroll-snapport">snapport</a>’s top edge;
however, this alignment is nonetheless not a valid <a href="#scroll-snap-position">snap position</a> if the entire <a href="#scroll-snap-area">snap area</a> is outside the <a href="#scroll-snapport">snapport</a>.</p>
<details class="note" role="note">
<summary>Why limit snapping to only when the element is visible?</summary>
As the <a href="https://www.webkit.org/blog/4017/scroll-snapping-with-css-snap-points/">WebKit implementers point out</a>,
extending a snap edge infinitely across the canvas
only allows for snapping gridded layouts,
and produces odd behavior for the user
when off-screen elements do not align
with on-screen elements.
(If this requirement is onerous for implementers however,
we can default to a gridded behavior
and introduce a switch to get smarter behavior.)
</details>
</ins>
<ins class="block">
<h4 class="heading settled" id="snap-overflow"><span class="secno">6.2.2. </span><span class="content"> Snapping Boxes that Overflow the Scrollport</span><a class="self-link" href="#snap-overflow"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-3">I-3</a></h4>
<p>If the <a href="#scroll-snap-area">snap area</a> is larger than the <a href="#scroll-snapport">snapport</a> in a particular axis,
and there are no other <a href="#scroll-snap-area">snap areas</a> within the <a href="#scroll-snapport">snapport</a>
that would provide a <a href="#snap-position">>snap position</a> aligning the overflowing <a href="#scroll-snap-area">snap area</a> within the <a>snapport</a>,
then any scroll position in which the <a href="#scroll-snap-area">snap area</a> covers the <a href="#scroll-snapport">snapport</a> is a valid <a href="#scroll-snap-position">snap position</a> in that axis.
The UA may use the specified alignment as a more precise target
for certain scroll operations (e.g. inertial scrolling or explicit paging).</p>
<div class="example" id="example-068e927e">
<a class="self-link" href="#example-068e927e"></a> For example, take the third code fragment in the previous example,
which had a photo as the area.
The author wants mandatory snapping from item to item,
but if the item happens to be larger than your viewport,
you want to be able to scroll around the whole thing once you’re over it.
<p>Since the <a href="#scroll-snap-area">snap area</a> is larger than the <a href="#scroll-snapport">snapport</a>,
while the area fully fills the viewport,
the container can be scrolled arbitrarily and will not try to snap back to its aligned position.
However, if the container is scrolled such that the area
no longer fully fills the viewport in an axis,
the area resists outward scrolling
until you fling out or pull it sufficiently to trigger snapping to a different <a href="#scroll-snap-position">snap position</a>.</p>
</div>
</ins>
<ins class="block">
<h4 class="heading settled" id="unreachable"><span class="secno">6.2.3. </span><span class="content"> Unreachable Snap Areas</span><a class="self-link" href="#unreachable"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-70">I-70</a></h4>
<p>If a <a href="#scroll-snap-position">snap position</a> is unreachable as specified,
such that aligning to it would require scrolling the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>’s viewport
past the edge of its <a>scrollable area</a>,
the <em>used</em> <a href="#scroll-snap-position">snap position</a> for this <a href="#scroll-snap-area">snap area</a> is the position resulting from scrolling <em>as much as possible</em> in each relevant axis
toward the desired <a href="#scroll-snap-position">snap position</a>.</p>
</ins>
<ins class="block">
<h3 class="heading settled" id="scroll-snap-stop"><span class="secno">6.3. </span><span class="content">Scroll Snap Limits: the <a class="property" href="#propdef-scroll-snap-stop">scroll-snap-stop</a> property</span><a class="self-link" href="#scroll-snap-stop"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-64">I-64</a></h3>
<table class="def propdef">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" id="propdef-scroll-snap-stop">scroll-snap-stop</dfn>
<tr class="value">
<th>Value:
<td class="prod">normal <a href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> always
<tr>
<th>Initial:
<td>normal
<tr>
<th>Applies to:
<td><a href="https://drafts.csswg.org/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Computed value:
<td>as specified
<tr>
<th>Animatable:
<td>no
</table>
<p>This property specifies whether the <a href="#scroll-snap-position">snap position</a> absorbs all remaining inertia during an <a href="#inertial-scroll">inertial scroll</a>,
or allows the <a href="#inertial-scroll">inertial scroll</a> to pass multiple <a href="#scroll-snap-position">snap positions</a> before coming to rest.
Values are defined as follows:</p>
<dl>
<dt><dfn class="css" id="valdef-scroll-snap-stop-normal">normal<a class="self-link" href="#valdef-scroll-snap-stop-normal"></a></dfn>
<dd> A <a href="#scroll-snap-position">snap position</a> defined by this element
does not interfere with the inertia
of an <a href="#inertial-scroll">inertial scroll</a> that is passing across it,
unless it is the landing <a href="#scroll-snap-position">snap position</a>.
<dt><dfn class="css" id="valdef-scroll-snap-stop-always">always<a class="self-link" href="#valdef-scroll-snap-stop-always"></a></dfn>
<dd>
A <a href="#scroll-snap-position">snap position</a> defined by this element,
when encountered by an <a href="#inertial-scroll">inertial scroll</a>,
absorbs all remaining inertia from an <a href="#inertial-scroll">inertial scroll</a>,
forcing a stop at this <a href="#scroll-snap-position">snap position</a>,
exactly as if the scroll had enough inertia to reach the <a href="#scroll-snap-position">snap position</a>,
but not enough to escape it.
<p class="note" role="note">Note: This means that if all snap positions in a scroller
have <a class="css" href="#propdef-scroll-snap-stop">scroll-snap-stop: always</a>,
an inertial scroll can only move one <a href="#scroll-snap-position">snap position</a> per inertial scroll action.</p>
</dl>
</ins>
<ins class="block">
<h2 class="heading settled" id="snap-concepts"><span class="secno">7. </span><span class="content">Snapping Mechanics</span><a class="self-link" href="#snap-concepts"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-68">I-68</a></h2>
<p>The precise model algorithm to select a <a href="#scroll-snap-position">snap position</a> to snap to
is intentionally left mostly undefined,
so that user agents can take into account sophisticated models of user intention and interaction
and adjust how they respond over time,
to best serve the user.</p>
<p>This section defines some useful concepts to aid in discussing scroll-snapping mechanics,
and provides some guidelines for what an effective scroll-snapping strategy might look like.
User agents are encouraged to adapt this guidance
and apply their own best judgement
when defining their own snapping behavior.
It also provides a small number of behavior requirements,
to ensure a minimum reasonable behavior that authors can depend on
when designing their interfaces with scroll-snapping in mind.</p>
<h3 class="heading settled" id="scroll-types"><span class="secno">7.1. </span><span class="content">Types of Scrolling Methods</span><a class="self-link" href="#scroll-types"></a></h3>
<p>When a page is scrolled,
the action is performed with
an intended end position
and/or an intended direction.
Each combination of these two things
defines a distinct category of scrolling,
which can be treated slightly differently:</p>
<dl>
<dt>
<p><dfn id="explicit-scroll">explicit scrolling</dfn></p>
<dd>
<p>A scroll is <a href="#explicit-scroll">explicit</a> if it has an intended end position,
but no intended direction.</p>
<p>This includes methods such as:</p>
<ul>
<li>
<p>a panning gesture,
released without momentum</p>
<li>
<p>manipulating the scrollbar "thumb" explicitly</p>
<li>
<p>programmatically scrolling via APIs such as <code class="idl"><a href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto">scrollTo()</a></code></p>
<li>
<p>tabbing through the document’s focusable elements</p>
<li>
<p>navigating to an anchor within the page</p>
</ul>
<dt>
<p><dfn id="inertial-scroll">inertial scrolling</dfn></p>
<dd>
<p>A scroll is <a href="#inertial-scroll">inertial</a> if it has both an intended end position
and an intended direction.</p>
<p>This includes methods such as:</p>
<ul>
<li>
<p>a "fling" gesture,
released with momentum
(the "intended" end position might be implicitly determined by the UA’s scrolling physics,
but the strength of the user’s fling still expresses a weak intention
about where the scroll should end up)</p>
<li>
<p>a mousewheel scroll</p>
<li>
<p>programmatically scrolling via APIs such as <code class="idl"><a href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollby">scrollBy()</a></code></p>
</ul>
<p>The scroll position that an <a href="#inertial-scroll">inertial</a> scroll would naturally land on
without further intervention is the <dfn id="natural-end-point">natural end-point</dfn>.</p>
<dt>
<p><dfn id="directional-scroll">directional scrolling</dfn></p>
<dd>
<p>A scroll is <a href="#directional-scroll">directional</a> if it has an intended direction,
but no intended end point.</p>
<p>This includes methods such as:</p>
<ul>
<li>
<p>pressing an arrow key on the keyboard</p>
</ul>
</dl>
<p>Additionally, because page layouts usually align things vertically and/or horizontally,
UAs sometimes <dfn id="axis-lock">axis-lock</dfn> a scroll when its direction
is sufficiently vertical or horizontal.
An <a href="#axis-lock">axis-locked</a> scroll is bound to only scroll along that axis.
This prevents,
for example,
a <em>nearly</em> horizontal fling gesture from gradually drifting up or down as well,
because it is very difficult to fling in a precisely horizontal line.</p>
</ins>
<ins class="block">
<h3 class="heading settled" id="snap-dimensions"><span class="secno">7.2. </span><span class="content">Axis vs Point-Snapping</span><a class="self-link" href="#snap-dimensions"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-67">I-67</a></h3>
<p class="issue" id="issue-323279de"><a class="self-link" href="#issue-323279de"></a> This feature is planned to be removed in the next publication
in order to reduce the feature-set of Level 1.
It is included here for future reference in defining Level 2.</p>
<p>There are two distinct <dfn id="snap-behavior">snapping behaviors</dfn> that a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> might engage in:</p>
<dl>
<dt>
<p><dfn id="axis-snapping">axis-snapping</dfn></p>
<dd>
<p>If a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> is <a href="#axis-snapping">axis-snapping</a>,
its descendants indicate a desired scroll position
in each axis of the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> independently,
with no dependent preference for what the other axis’s scroll position should be.</p>
<p class="note" role="note">Note: This is the “default” type of <a href="#snap-behavior">snap behavior</a> that most <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll containers</a> will want to use,
and so the <span class="css">scroll-snap-type</span> property intentionally defaults to it.</p>
<p class="note" role="note">Note: An element in an <a href="#axis-snapping">axis-snapping</a> <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> can declare two <a href="#scroll-snap-position">snap positions</a>,
one in each axis.
If one of the element’s <a href="#scroll-snap-position">snap positions</a> is chosen in one axis,
this has no bearing on the other dimension’s <a href="#scroll-snap-position">snap position</a>—<wbr>it might be chosen,
or a different element’s <a href="#scroll-snap-position">snap position</a> might be chosen for that axis,
or that axis might not snap at all.</p>
<dt>
<p><dfn id="point-snapping">point-snapping</dfn></p>
<dd>
<p>If a <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> is <a href="#point-snapping">point-snapping</a>,
its descendants indicate a desired scroll position
in both axises of the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> simultaneously—<wbr>in other words,
some point in the descendant must be aligned to a corresponding point in the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a>.</p>
<p>This type of <a href="#snap-behavior">snapping behavior</a> is intended for "two-dimensional" panning-type layouts,
such as cities on a map
(using <a class="css" href="#valdef-scroll-snap-type-proximity">proximity</a> 2D snap positions to snap a city to the center of the display when it gets close),
or a tiled image gallery
(using <a class="css" href="#valdef-scroll-snap-type-mandatory">mandatory</a> 2D snap positions to force each image to be centered on the screen).
In both of these cases,
it would look weird if the horizontal scrolling was aligned to one element
while the vertical was aligned to a different element
(which is the behavior you’d get if the <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> was <a href="#axis-snapping">axis-snapping</a>).</p>
</dl>
</ins>
<ins class="block">
<h3 class="heading settled" id="choosing"><span class="secno">7.3. </span><span class="content">Choosing Snap Positions</span><a class="self-link" href="#choosing"></a>
<a target="delta" class="delta comment" href="https://drafts.csswg.org/css-scroll-snap/issues-by-issue#issue-68">I-68</a></h3>
<p>A <a href="https://drafts.csswg.org/css-snappoints-1/#scroll-container">scroll container</a> can have many <a href="#scroll-snap-area">snap areas</a> scattered throughout its <a>scrollable area</a>.
A naive algorithm for selecting a <a href="#scroll-snap-position">snap position</a> can produce behavior that is unintuitive for users,
so care is required when designing a selection algorithm.
Here are a few pointers that can aid in the selection process:</p>
<ul>
<li>
<p><a href="#scroll-snap-position">Snap positions</a> should be chosen to minimize the distance between the end-point