-
Notifications
You must be signed in to change notification settings - Fork 707
/
Copy pathProposal.html
2176 lines (2161 loc) · 164 KB
/
Proposal.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 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">
<meta content="A brief description of an alternate model for scroll-snapping." name="abstract">
<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>/* style-md-lists */
/* This is a weird hack for me not yet following the commonmark spec
regarding paragraph and lists. */
[data-md] > :first-child {
margin-top: 0;
}
[data-md] > :last-child {
margin-bottom: 0;
}</style>
<style>/* style-selflinks */
.heading, .issue, .note, .example, li, dt {
position: relative;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
li > a.self-link {
left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: gray;
color: white;
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: black;
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }</style>
<style>/* style-counters */
body {
counter-reset: example figure issue;
}
.issue {
counter-increment: issue;
}
.issue:not(.no-marker)::before {
content: "Issue " counter(issue);
}
.example {
counter-increment: example;
}
.example:not(.no-marker)::before {
content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
content: "Invalid Example" counter(example);
}
figure {
counter-increment: figure;
}
figcaption:not(.no-marker)::before {
content: "Figure " counter(figure);
}</style>
<style>/* style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: #005a9c;
font-size: inherit;
font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
content: "‘";
}
.css::after, .property::after, .descriptor::after {
content: "’";
}
.property, .descriptor {
/* Don't wrap property and descriptor names */
white-space: nowrap;
}
.type { /* CSS value <type> */
font-style: italic;
}
pre .property::before, pre .property::after {
content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
content: "’";
}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
content: "";
}
[data-link-type=element],
[data-link-type=element-attr] {
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
[data-link-type=biblio] {
white-space: pre;
}</style>
<style>/* style-dfn-panel */
.dfn-panel {
position: absolute;
z-index: 35;
height: auto;
width: -webkit-fit-content;
width: fit-content;
max-width: 300px;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-syntax-highlighting */
.highlight:not(.idl) { 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; }
.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 .cm { color: #708090 } /* Comment.Multiline */
.highlight .cp { color: #708090 } /* Comment.Preproc */
.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: #222222 } /* 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 */
</style>
<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/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">CSS Scroll Snapping Change Proposal</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Unofficial Proposal Draft, <time class="dt-updated" datetime="2016-08-02">2 August 2016</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="https://drafts.csswg.org/css-scroll-snap/">https://drafts.csswg.org/css-scroll-snap/</a>
<dt>Issue Tracking:
<dd><a href="https://github.com/w3c/csswg-drafts/issues/">GitHub</a>
<dd><a href="#issues-index">Inline In Spec</a>
<dt class="editor">Editors:
<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"><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</span>)
</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> © 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. </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>A brief description of an alternate model for scroll-snapping.</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></p>
</div>
<div data-fill-with="at-risk">
<p>The following features are at-risk, and may be dropped during the CR period: </p>
<ul>
<li><a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-point">point</a> value of <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-type">scroll-snap-type</a>
</ul>
<p>“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.</p>
</div>
<nav data-fill-with="table-of-contents" 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> <span class="content">Introduction</span></a>
<li><a href="#use-cases"><span class="secno">2</span> <span class="content">Use Cases</span></a>
<li><a href="#proposal"><span class="secno">3</span> <span class="content">Overview of Change</span></a>
<li><a href="#snap-model"><span class="secno">4</span> <span class="content">Scroll Snapping Model</span></a>
<li>
<a href="#snap-container"><span class="secno">5</span> <span class="content">Capturing Scroll Snap Areas: Properties on the scroll container</span></a>
<ol class="toc">
<li><a href="#snap-type"><span class="secno">5.1</span> <span class="content">Scroll Snapping Rules: the <span class="property">scroll-snap-type</span> property</span></a>
<li><a href="#snap-padding"><span class="secno">5.2</span> <span class="content">Scroll Snapport: the <span class="property">scroll-snap-padding</span> property</span></a>
</ol>
<li>
<a href="#element"><span class="secno">6</span> <span class="content">Aligning Scroll Snap Areas: Properties on the scrolling content</span></a>
<ol class="toc">
<li><a href="#scroll-snap-areas"><span class="secno">6.1</span> <span class="content">Scroll Snapping Margin: the <span class="property">scroll-snap-margin</span> property</span></a>
<li>
<a href="#scroll-snap-alignment"><span class="secno">6.2</span> <span class="content">Scroll Snapping Alignment: the <span class="property">scroll-snap-align</span> property</span></a>
<ol class="toc">
<li><a href="#snap-scope"><span class="secno">6.2.1</span> <span class="content"> Scoping Valid Snap Positions to Visible Boxes</span></a>
<li><a href="#snap-overflow"><span class="secno">6.2.2</span> <span class="content"> Snapping Boxes that Overflow the Scrollport</span></a>
<li><a href="#unreachable"><span class="secno">6.2.3</span> <span class="content"> Unreachable Snap Areas</span></a>
</ol>
<li><a href="#scroll-snap-stop"><span class="secno">6.3</span> <span class="content">Scroll Snap Limits: the <span class="property">scroll-snap-stop</span> property</span></a>
</ol>
<li>
<a href="#snap-concepts"><span class="secno">7</span> <span class="content">Snapping Mechanics</span></a>
<ol class="toc">
<li><a href="#scroll-types"><span class="secno">7.1</span> <span class="content">Types of Scrolling Methods</span></a>
<li><a href="#snap-dimensions"><span class="secno">7.2</span> <span class="content">Axis vs Point-Snapping</span></a>
<li><a href="#choosing"><span class="secno">7.3</span> <span class="content">Choosing Snap Positions</span></a>
</ol>
<li>
<a href="#longhands"><span class="secno"></span> <span class="content">Appendix A: Longhands</span></a>
<ol class="toc">
<li><a href="#padding-longhands-physical"><span class="secno"></span> <span class="content">Physical Longhands for <span class="property">scroll-snap-padding</span></span></a>
<li><a href="#padding-longhands-logical"><span class="secno"></span> <span class="content">Flow-relative Longhands for <span class="property">scroll-snap-padding</span></span></a>
<li><a href="#area-longhands-physical"><span class="secno"></span> <span class="content">Physical Longhands for <span class="property">scroll-snap-margin</span></span></a>
<li><a href="#area-longhands-logical"><span class="secno"></span> <span class="content">Flow-relative Longhands for <span class="property">scroll-snap-margin</span></span></a>
</ol>
<li><a href="#priv-sec"><span class="secno">8</span> <span class="content">Privacy and Security Considerations</span></a>
<li><a href="#acknowledgements"><span class="secno">9</span> <span class="content">Acknowledgements</span></a>
<li>
<a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
<ol class="toc">
<li><a href="#document-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
<li><a href="#conform-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
<li>
<a href="#conform-responsible"><span class="secno"></span> <span class="content"> Requirements for Responsible Implementation of CSS</span></a>
<ol class="toc">
<li><a href="#conform-partial"><span class="secno"></span> <span class="content"> Partial Implementations</span></a>
<li><a href="#conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a>
<li><a href="#conform-testing"><span class="secno"></span> <span class="content"> Implementations of CR-level Features</span></a>
</ol>
</ol>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
</ol>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
</ol>
</nav>
<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>
<p>We think scroll snapping is a great idea, and fully support exposing this functionality through CSS. However, a major weakness of the current spec is the way it conceives snapping on a coordinate model rather than a box model. This requires a lot of manual calculations in figuring out the correct coordinates from the box model; and also makes sensible scroll-snap settings dependent on the relative sizes of the viewport and the snappable contents, causing problems for users are unexpectedly large and/or small screens (a problem commonly ignored by many authors).</p>
<p>This proposal builds off of roc’s model, using an area-snapping model to intelligently handle adaptation to multiple screen sizes. It also adds group alignment as a built-in concept, rather than requiring authors to build one in JavaScript.</p>
<h2 class="heading settled" data-level="2" id="use-cases"><span class="secno">2. </span><span class="content">Use Cases</span><a class="self-link" href="#use-cases"></a></h2>
<div class="example" id="example-00540445">
<a class="self-link" href="#example-00540445"></a> Use Case 1: Snapping to the start or middle of each box
e.g. address book (start) or photo album (middle)
<ol>
<li data-md="">
<p>Snapping to 0.25rem above the top of each heading</p>
<pre class="lang-css highlight"><span></span><span class="nt">:root </span><span class="p">{</span> <span class="k">scroll-snap-type</span><span class="p">:</span> proximity<span class="p">;</span> <span class="p">}</span>
<span class="nt">h1, h2, h3, h4, h5, h6 </span><span class="p">{</span>
<span class="k">scroll-snap-align</span><span class="p">:</span> start<span class="p">;</span>
<span class="k">scroll-snap-margin</span><span class="p">:</span> <span class="m">0</span>.25em;
}
</pre>
<li data-md="">
<p>Snapping to the center of each photo</p>
<pre class="lang-css highlight"><span></span><span class="nt">:root </span><span class="p">{</span> <span class="k">scroll-snap-type</span><span class="p">:</span> mandatory<span class="p">;</span> <span class="p">}</span>
<span class="nt">img </span><span class="p">{</span> <span class="k">scroll-snap-align</span><span class="p">:</span> center<span class="p">;</span> <span class="p">}</span>
</pre>
</ol>
</div>
<div class="example" id="example-ede71b3c">
<a class="self-link" href="#example-ede71b3c"></a> Use Case 2: Snapping to boxes (or points) in 2D
e.g. on a map, where you want to snap points of interest to the
center, or a flow-chart diagram, where you want to snap the edges
of each box into the visible area. In both cases, you don’t want
objects wholly outside the visible area to influence snapping.
<ol>
<li data-md="">
<p>Snapping each flow chart entry to within the viewport when it falls near the edge:</p>
<pre class="lang-css highlight"><span></span><span class="nt">:root </span><span class="p">{</span>
<span class="k">scroll-snap-type</span><span class="p">:</span> proximity<span class="p">;</span>
<span class="p">}</span>
<span class="nt">li </span><span class="p">{</span>
<span class="k">scroll-snap-align</span><span class="p">:</span> start<span class="p">;</span>
<span class="p">}</span>
</pre>
<li data-md="">
<p>Snapping each city on a map to the center of the viewport,
but only once it gets near the center in both dimensions:</p>
<pre class="lang-css highlight"><span></span><span class="nt">:root </span><span class="p">{</span>
<span class="k">scroll-snap-type</span><span class="p">:</span> proximity<span class="p">;</span>
<span class="p">}</span>
<span class="nt">.city </span><span class="p">{</span>
<span class="k">scroll-snap-align</span><span class="p">:</span> center<span class="p">;</span>
<span class="p">}</span>
</pre>
</ol>
</div>
<div class="example" id="example-002b6804">
<a class="self-link" href="#example-002b6804"></a> Use Case 3: Slideshow, where successive slides are arranged horizontally,
and sometimes "detail" slides are placed below the "main" slide for that point.
<pre class="lang-html highlight"><span></span><span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slides"</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide"</span><span class="p">></span>...<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide"</span><span class="p">></span>...<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide details"</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide"</span><span class="p">></span>...<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide"</span><span class="p">></span>...<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">"slide"</span><span class="p">></span>...<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"></</span><span class="nt">div</span><span class="p">></span>
<span class="p"><</span><span class="nt">style</span><span class="p">></span>
<span class="nc">.slides</span> <span class="p">{</span>
<span class="nb">display</span><span class="o">:</span> <span class="n">flex</span><span class="p">;</span>
<span class="n">flex</span><span class="o">-</span><span class="n">flow</span><span class="o">:</span> <span class="n">row</span><span class="p">;</span>
<span class="nb">scroll</span><span class="o">-</span><span class="n">snap</span><span class="o">-</span><span class="n">type</span><span class="o">:</span> <span class="n">mandatory</span><span class="p">;</span>
<span class="nb">overflow-x</span><span class="o">:</span> <span class="nb">scroll</span><span class="p">;</span>
<span class="nb">width</span><span class="o">:</span> <span class="m">100</span><span class="n">vw</span><span class="p">;</span>
<span class="nb">height</span><span class="o">:</span> <span class="m">100</span><span class="n">vh</span><span class="p">;</span>
<span class="p">}</span>
<span class="nc">.slide</span> <span class="p">{</span>
<span class="nb">scroll</span><span class="o">-</span><span class="n">snap</span><span class="o">-</span><span class="n">align</span><span class="o">:</span> <span class="n">start</span><span class="p">;</span>
<span class="nb">width</span><span class="o">:</span> <span class="m">100</span><span class="n">vw</span><span class="p">;</span>
<span class="nb">min-height</span><span class="o">:</span> <span class="m">100</span><span class="n">vh</span><span class="p">;</span>
<span class="p">}</span>
<span class="nc">.slide.details</span> <span class="p">{</span>
<span class="nb">display</span><span class="o">:</span> <span class="n">flex</span><span class="p">;</span>
<span class="n">flex</span><span class="o">-</span><span class="n">flow</span><span class="o">:</span> <span class="n">column</span><span class="p">;</span>
<span class="nb">scroll</span><span class="o">-</span><span class="n">snap</span><span class="o">-</span><span class="n">type</span><span class="o">:</span> <span class="n">mandatory</span><span class="p">;</span>
<span class="nb">overflow-y</span><span class="o">:</span> <span class="nb">scroll</span><span class="p">;</span>
<span class="p">}</span>
<span class="p"></</span><span class="nt">style</span><span class="p">></span>
</pre>
</div>
<h2 class="heading settled" data-level="3" id="proposal"><span class="secno">3. </span><span class="content">Overview of Change</span><a class="self-link" href="#proposal"></a></h2>
<p>On the scroll container:</p>
<table class="data">
<thead>
<tr>
<th>Spec
<th>Proposal
<th>Priority
<tbody>
<tr>
<td><a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-1">scroll-snap-type: none | mandatory | proximity</a>
<td><a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-2">scroll-snap-type: none | [ mandatory | proximity ] || [ x | y | block | inline | both | point]</a>
<td>High priority
<tr>
<td>''scroll-snap-destination: <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-backgrounds-3/#position"><position></a>''
<td>''scroll-snap-padding: [ <a class="production css" data-link-type="type" 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" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#percentage-value"><percentage></a> ]{1,4}''
<td>
</table>
<p>On the children:</p>
<table class="data">
<thead>
<tr>
<th>Spec
<th>Proposal
<th>Priority
<tbody>
<tr>
<td>''scroll-snap-coordinate: <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-backgrounds-3/#position"><position></a>#''
<td><a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align-1">scroll-snap-align: [ none | start | end | center ]{1,2}</a>
<td>High priority
<tr>
<td>n/a
<td>''scroll-snap-margin: <a class="production css" data-link-type="type" 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}''
<td>High priority
</table>
<h2 class="heading settled" data-level="4" id="snap-model"><span class="secno">4. </span><span class="content">Scroll Snapping Model</span><a class="self-link" href="#snap-model"></a></h2>
<p>This module introduces control over <dfn class="dfn-paneled" data-dfn-type="dfn" data-local-lt="snap position" data-lt="scroll snap position" data-noexport="" id="scroll-snap-position">scroll snap positions</dfn>,
which are scroll positions that produce particular alignments
of content within a scrollable viewport.
Using the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-3">scroll-snap-type</a> property on the relevant <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
the author can request a particular bias
for the viewport to land on a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-1">snap position</a> after scrolling operations.</p>
<p><a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-2">Snap positions</a> are specified
as a particular alignment (<a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align-2">scroll-snap-align</a>)
of a box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-1">scroll snap area</a> (its border bounding box, as modified by <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-margin" id="ref-for-propdef-scroll-snap-margin-1">scroll-snap-margin</a>)
within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-1">snapport</a> (its scrollport, as reduced by <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-padding" id="ref-for-propdef-scroll-snap-padding-1">scroll-snap-padding</a>).
This is conceptually equivalent to specifying the alignment of
an <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-subject">alignment subject</a> within an <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a>.
A scroll position that satisfies the specified alignment
is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-3">snap position</a>.</p>
<p>The act of adjusting the scroll position
of a scroll container’s scrollport
such that it is aligned to a snap position
is called <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="snap | snapping | snapped" data-noexport="" id="snap">snapping</dfn>,
and a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> is said to be <a data-link-type="dfn" href="#snap" id="ref-for-snap-1">snapped</a> to a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-4">snap position</a> if its scrollport’s scroll position
is that <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-5">snap position</a> and there is no active scrolling operation.
The CSS Scroll Snap Module
intentionally does not specify nor mandate
any precise animations or physics used to enforce <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-6">snap positions</a>;
this is left up to the user agent.</p>
<p><a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-7">Snap positions</a> only affect the nearest ancestor <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> on the element’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#containing-block-chain">containing block chain</a>.</p>
<h2 class="heading settled" data-level="5" id="snap-container"><span class="secno">5. </span><span class="content">Capturing Scroll Snap Areas: Properties on the scroll container</span><a class="self-link" href="#snap-container"></a></h2>
<h3 class="heading settled" data-level="5.1" id="snap-type"><span class="secno">5.1. </span><span class="content">Scroll Snapping Rules: the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-4">scroll-snap-type</a> property</span><a class="self-link" href="#snap-type"></a></h3>
<table class="def propdef" data-link-for-hint="scroll-snap-type">
<tbody>
<tr>
<th>Name:
<td><dfn class="dfn-paneled css" data-dfn-type="property" data-export="" id="propdef-scroll-snap-type">scroll-snap-type</dfn>
<tr class="value">
<th>Value:
<td class="prod">none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ proximity <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> mandatory ] <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-any">||</a> [ x <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> y <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> block <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> inline <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> both <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> point ]
<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" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-5">scroll-snap-type</a> property specifies
whether a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> is a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container-1">scroll snap container</a>,
how strictly it <a data-link-type="dfn" href="#snap" id="ref-for-snap-2">snaps</a>,
and which axes are considered.</p>
<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>
<p>The <dfn data-dfn-type="dfn" data-lt="strictness value" data-noexport="" id="strictness-value">strictness values<a class="self-link" href="#strictness-value"></a></dfn> (<a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-none" id="ref-for-valdef-scroll-snap-type-none-1">none</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-proximity" id="ref-for-valdef-scroll-snap-type-proximity-1">proximity</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-mandatory" id="ref-for-valdef-scroll-snap-type-mandatory-1">mandatory</a>)
specify how strictly <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-8">snap positions</a> are enforced on the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> (by forcing an adjustment to the scroll position).
Values are defined as follows:</p>
<dl>
<dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-none">none</dfn>
<dd>
If specified on a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> must not <a data-link-type="dfn" href="#snap" id="ref-for-snap-3">snap</a>:
all scroll positions are equally valid.
<p>If specified on a non-<a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
this value has no effect.</p>
<dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-proximity">proximity</dfn>
<dd>
If specified on a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> may <a data-link-type="dfn" href="#snap" id="ref-for-snap-4">snap</a> to a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-9">snap position</a> at the termination of a scroll,
at the discretion of the UA given the parameters of the scroll.
<p>If specified on a non-<a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
this value “traps” descendant boxes’ <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-10">snap positions</a>,
preventing them from affecting any ancestor <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll containers</a>.</p>
<dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-mandatory">mandatory</dfn>
<dd>
If specified on a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> is required to be <a data-link-type="dfn" href="#snap" id="ref-for-snap-5">snapped</a> to a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-11">snap position</a> when there are no active scrolling operations.
That is, it must <a data-link-type="dfn" href="#snap" id="ref-for-snap-6">snap</a> to a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-12">snap position</a> at the termination of a scroll, if any such exist.
(If none exist, then no snapping occurs.)
<p>If specified on a non-<a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>,
this value “traps” descendant boxes’ <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-13">snap positions</a>,
preventing them from affecting any ancestor <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll containers</a>.</p>
</dl>
<p>A box <dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" id="captures-snap-positions">captures snap positions</dfn> if it is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <em>or</em> has a value other than <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-none" id="ref-for-valdef-scroll-snap-type-none-2">none</a> for <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-6">scroll-snap-type</a>.
If a box’s nearest <a data-link-type="dfn" href="#captures-snap-positions" id="ref-for-captures-snap-positions-1">snap-position capturing</a> ancestor
on its <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#containing-block-chain">containing block chain</a> is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> with a non-<a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-none" id="ref-for-valdef-scroll-snap-type-none-3">none</a> value for <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type-7">scroll-snap-type</a>,
that is the box’s <dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" data-local-lt="snap container" id="scroll-snap-container">scroll snap container</dfn>.
Otherwise, the box has no <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container-2">scroll snap container</a>,
and its <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-14">snap positions</a> do not trigger <a data-link-type="dfn" href="#snap" id="ref-for-snap-7">snapping</a>.</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>
<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.</p>
<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>
<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.</p>
</div>
<p>The <dfn data-dfn-type="dfn" data-lt="axis value" data-noexport="" id="axis-value">axis values<a class="self-link" href="#axis-value"></a></dfn> specify what axis(es) are affected by <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-15">snap positions</a>,
and whether <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-16">snap positions</a> are evaluated independently per axis,
or together as a 2D point.
Values are defined as follows:</p>
<dl>
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-x">x<a class="self-link" href="#valdef-scroll-snap-type-x"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-1">axis-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-17">snap positions</a> in its horizontal axis only.
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-y">y<a class="self-link" href="#valdef-scroll-snap-type-y"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-2">axis-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-18">snap positions</a> in its vertical axis only.
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-block">block<a class="self-link" href="#valdef-scroll-snap-type-block"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-3">axis-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-19">snap positions</a> in its block axis only.
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-inline">inline<a class="self-link" href="#valdef-scroll-snap-type-inline"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-4">axis-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-20">snap positions</a> in its inline axis only.
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-both">both<a class="self-link" href="#valdef-scroll-snap-type-both"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-5">axis-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-21">snap positions</a> in both of its axises independently
(potentially snapping to different elements in each axis).
<dt><dfn class="css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export="" id="valdef-scroll-snap-type-point">point<a class="self-link" href="#valdef-scroll-snap-type-point"></a></dfn>
<dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> <a data-link-type="dfn" href="#point-snapping" id="ref-for-point-snapping-1">point-snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-22">snap positions</a> in both axises simultaneously,
treating each element’s <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-23">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:</p>
<ul>
<li data-md="">
<p>If the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> is only scrollable in one axis
(only one axis has its <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-overflow-4/#propdef-overflow">overflow</a> set to <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-overflow-4/#valdef-overflow-auto">auto</a> or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-overflow-4/#valdef-overflow-scroll">scroll</a>)
it <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-6">axis-snaps</a> in the scrollable axis only.</p>
<li data-md="">
<p>Otherwise, it <a data-link-type="dfn" href="#axis-snapping" id="ref-for-axis-snapping-7">axis-snaps</a> in its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a> only.</p>
</ul>
<p>If the content or layout of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> changes
(e.g. content is added, moved, deleted, resized),
the UA must re-evaluate, and potentially re-<a data-link-type="dfn" href="#snap" id="ref-for-snap-8">snap</a> if necessary,
the resulting scroll position
once the positions of the content have restabilized.
This can result in no snapping in some cases
(e.g. if there are no nearby <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-24">snap positions</a> for a <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-proximity" id="ref-for-valdef-scroll-snap-type-proximity-2">proximity</a>-snapping <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>).
However, if there was a previously-<a data-link-type="dfn" href="#snap" id="ref-for-snap-9">snapped</a> <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-25">snap position</a> (associated with the same element)
that still exists after such changes,
the UA must remain <a data-link-type="dfn" href="#snap" id="ref-for-snap-10">snapped</a> to it—<wbr>even if the changes would have placed a different <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-26">snap position</a> closer to the current scroll position.
Otherwise, the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> must be re-<a data-link-type="dfn" href="#snap" id="ref-for-snap-11">snapped</a> as if the user had scrolled to its current scroll position
(as an <a data-link-type="dfn" href="#explicit-scroll" id="ref-for-explicit-scroll-1">explicit scroll</a>, if no other scroll operation is active).</p>
<h3 class="heading settled" data-level="5.2" id="snap-padding"><span class="secno">5.2. </span><span class="content">Scroll Snapport: the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-padding" id="ref-for-propdef-scroll-snap-padding-2">scroll-snap-padding</a> property</span><a class="self-link" href="#snap-padding"></a></h3>
<table class="def propdef" data-link-for-hint="scroll-snap-padding">
<tbody>
<tr>
<th>Name:
<td><dfn class="dfn-paneled css" data-dfn-type="property" data-export="" id="propdef-scroll-snap-padding">scroll-snap-padding</dfn>
<tr class="value">
<th>Value:
<td class="prod">[ <a class="production css" data-link-type="type" 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 data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-3/#percentage-value"><percentage></a> ]<a data-link-type="grammar" 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 data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll containers</a>
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>relative to the corresponding dimension of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s scrollport
<tr>
<th>Computed value:
<td>as specified, with lengths made absolute
<tr>
<th>Animatable:
<td>as length, percentage, or calc
</table>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-padding" id="ref-for-propdef-scroll-snap-padding-3">scroll-snap-padding</a> property defines the <dfn class="dfn-paneled" data-dfn-type="dfn" data-local-lt="snapport" data-noexport="" id="scroll-snapport">scroll snapport</dfn>—<wbr>the area of the scrollport that is used as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a> for the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-2">scroll snap areas</a> when calculating <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-27">snap positions</a>.
Values are interpreted as for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/box.html#propdef-padding">padding</a>,
and specify inward offsets from each edge of the scrollport.</p>
<div class="example" id="example-3435d351">
<a class="self-link" href="#example-3435d351"></a> In this example, points of interest in a map are centered
within the portion of the viewport that does not include the toolbar overlay.
<pre>map {
overflow: scroll;
scroll-snap-type: proximity;
scroll-snap-padding: 3em 0 0 0;
}
toolbar {
position: absolute;
margin: 0.5em;
top: 0; left: 0; right: 0;
height: 2em;
}
city {
scroll-snap-align: center;
}
</pre>
</div>
<p>This property is a <a data-link-type="dfn" 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.</p>
<h2 class="heading settled" data-level="6" id="element"><span class="secno">6. </span><span class="content">Aligning Scroll Snap Areas: Properties on the scrolling content</span><a class="self-link" href="#element"></a></h2>
<h3 class="heading settled" data-level="6.1" id="scroll-snap-areas"><span class="secno">6.1. </span><span class="content">Scroll Snapping Margin: the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-margin" id="ref-for-propdef-scroll-snap-margin-2">scroll-snap-margin</a> property</span><a class="self-link" href="#scroll-snap-areas"></a></h3>
<table class="def propdef" data-link-for-hint="scroll-snap-margin">
<tbody>
<tr>
<th>Name:
<td><dfn class="dfn-paneled css" data-dfn-type="property" data-export="" id="propdef-scroll-snap-margin">scroll-snap-margin</dfn>
<tr class="value">
<th>Value:
<td class="prod"><a class="production css" data-link-type="type" 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 data-link-type="grammar" 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>as length
</table>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-margin" id="ref-for-propdef-scroll-snap-margin-3">scroll-snap-margin</a> property defines
the <dfn class="dfn-paneled" data-dfn-type="dfn" data-local-lt="snap area" data-noexport="" id="scroll-snap-area">scroll snap area</dfn> that is used for snapping this box to the viewport.
The <a class="production css" data-link-type="type" 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" data-link-type="propdesc" href="https://drafts.csswg.org/css2/box.html#propdef-margin">margin</a> or <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-backgrounds-3/#border-image-outset">border-image-outset</a>).
The <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-3">scroll snap area</a> is the rectangular bounding box of the transformed border box,
plus the specified outsets,
axis-aligned in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container’s</a> coordinate space.</p>
<p class="note" role="note">Note: This ensures that the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-4">scroll snap area</a> is always rectangular
and axis-aligned to the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container’s</a> coordinate space.</p>
<p>This property is a <a data-link-type="dfn" 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.</p>
<h3 class="heading settled" data-level="6.2" id="scroll-snap-alignment"><span class="secno">6.2. </span><span class="content">Scroll Snapping Alignment: the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align-3">scroll-snap-align</a> property</span><a class="self-link" href="#scroll-snap-alignment"></a></h3>
<table class="def propdef" data-link-for-hint="scroll-snap-align">
<tbody>
<tr>
<th>Name:
<td><dfn class="dfn-paneled css" data-dfn-type="property" data-export="" id="propdef-scroll-snap-align">scroll-snap-align</dfn>
<tr class="value">
<th>Value:
<td class="prod">[ none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> center ]<a data-link-type="grammar" 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" data-link-type="propdesc" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align-4">scroll-snap-align</a> property specifies
the box’s <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-28">snap position</a> as an alignment of
its <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-5">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" id="ref-for-scroll-snap-container-3">snap container’s</a> <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-2">snapport</a> (as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container">alignment container</a>).
The two values specify snapping alignment
in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a> and <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>, respectively.
If only one value is specified, the second value defaults to the same value.</p>
<div class="example" id="example-b4976a9e">
<a class="self-link" href="#example-b4976a9e"></a> The following example aligns the start edge of the box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-6">snap area</a> to the start edge of the scroll container’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-3">snapport</a>:
<pre>section { scroll-snap-align: start; }</pre>
<p>The following example aligns the center of each city
to the center of the scroll container’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-4">snapport</a>,
snapping only when the city is centered in both axes:</p>
<pre>.map { scroll-snap-type: proximity point; }
.map .city { scroll-snap-align: center; }
</pre>
<p>The following example aligns the center of each photo
to the center of the scroll container’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-5">snapport</a>,
snapping independently in each axis:</p>
<pre>.photos { scroll-snap-type: mandatory both; }
img { scroll-snap-align: center; }
</pre>
</div>
<p>Values are defined as follows:</p>
<dl>
<dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export="" id="valdef-scroll-snap-align-none">none</dfn>
<dd> This box does not define a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-29">snap position</a> in the specified axis.
<dt><dfn class="css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export="" id="valdef-scroll-snap-align-start">start<a class="self-link" href="#valdef-scroll-snap-align-start"></a></dfn>
<dd> Start alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-7">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-6">snapport</a> is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-30">snap position</a> in the specified axis.
<dt><dfn class="css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export="" id="valdef-scroll-snap-align-end">end<a class="self-link" href="#valdef-scroll-snap-align-end"></a></dfn>
<dd> End alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-8">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-7">snapport</a> is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-31">snap position</a> in the specified axis.
<dt><dfn class="css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export="" id="valdef-scroll-snap-align-center">center<a class="self-link" href="#valdef-scroll-snap-align-center"></a></dfn>
<dd> Center alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-9">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-8">snapport</a> is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-32">snap position</a> in the specified axis.
</dl>
<p>If the element’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a> is <a data-link-type="dfn" href="#point-snapping" id="ref-for-point-snapping-2">point-snapping</a>,
and this property does not specify a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-33">snap position</a> in both axises
(that is, it contains <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-align-none" id="ref-for-valdef-scroll-snap-align-none-1">none</a>),
the element does not contribute any <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-34">snap positions</a> at all.</p>
<p>For all of these values,
the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#block">block</a> or <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#inline">inline</a> axis
is relative to the element’s parent’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#writing-mode">writing mode</a>.</p>
<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>
<details class="note" role="note">
<summary>Why no <a class="production css" data-link-type="type" 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" data-link-type="type" 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" data-link-type="propdesc" href="https://drafts.csswg.org/css-align-3/#propdef-align-self">align-self</a> and <a class="property" data-link-type="propdesc" 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" data-link-type="propdesc" href="#propdef-scroll-snap-margin" id="ref-for-propdef-scroll-snap-margin-4">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" data-link-type="propdesc" href="#propdef-scroll-snap-margin" id="ref-for-propdef-scroll-snap-margin-5">scroll-snap-margin</a>.</p>
</details>
<h4 class="heading settled" data-level="6.2.1" 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></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 data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-35">snap position</a> only if at least part of the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-10">snap area</a> is within the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-9">snapport</a>.
For example, a <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-11">snap area</a> is top-aligned to the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-10">snapport</a> if its top edge is coincident with the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-11">snapport</a>’s top edge;
however, this alignment is nonetheless not a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-36">snap position</a> if the entire <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-12">snap area</a> is outside the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-12">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>
<h4 class="heading settled" data-level="6.2.2" 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></h4>
<p>If the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-13">snap area</a> is larger than the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-13">snapport</a> in a particular axis,
and there are no other <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-14">snap areas</a> within the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-14">snapport</a> that would provide a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-37">snap position</a> aligning the overflowing <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-15">snap area</a> within the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-15">snapport</a>,
then any scroll position in which the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-16">snap area</a> covers the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-16">snapport</a> is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-38">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-9e711241">
<a class="self-link" href="#example-9e711241"></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 data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-17">snap area</a> is larger than the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport-17">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 data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-39">snap position</a>.</p>
</div>
<h4 class="heading settled" data-level="6.2.3" id="unreachable"><span class="secno">6.2.3. </span><span class="content"> Unreachable Snap Areas</span><a class="self-link" href="#unreachable"></a></h4>
<p>If a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-40">snap position</a> is unreachable as specified,
such that aligning to it would require scrolling the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container">scroll container</a>’s viewport
past the edge of its <a data-link-type="dfn">scrollable area</a>,
the <em>used</em> <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-41">snap position</a> for this <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area-18">snap area</a> is the position resulting from scrolling <em>as much as possible</em> in each relevant axis
toward the desired <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-42">snap position</a>.</p>
<h3 class="heading settled" data-level="6.3" id="scroll-snap-stop"><span class="secno">6.3. </span><span class="content">Scroll Snap Limits: the <a class="property" data-link-type="propdesc" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop-1">scroll-snap-stop</a> property</span><a class="self-link" href="#scroll-snap-stop"></a></h3>
<table class="def propdef" data-link-for-hint="scroll-snap-stop">
<tbody>
<tr>
<th>Name:
<td><dfn class="dfn-paneled css" data-dfn-type="property" data-export="" id="propdef-scroll-snap-stop">scroll-snap-stop</dfn>
<tr class="value">
<th>Value:
<td class="prod">normal <a data-link-type="grammar" 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 data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-43">snap position</a> absorbs all remaining inertia during an <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-1">inertial scroll</a>,
or allows the <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-2">inertial scroll</a> to pass multiple <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-44">snap positions</a> before coming to rest.
Values are defined as follows:</p>
<dl>
<dt><dfn class="css" data-dfn-for="scroll-snap-stop" data-dfn-type="value" data-export="" id="valdef-scroll-snap-stop-normal">normal<a class="self-link" href="#valdef-scroll-snap-stop-normal"></a></dfn>
<dd> A <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-45">snap position</a> defined by this element
does not interfere with the inertia
of an <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-3">inertial scroll</a> that is passing across it,
unless it is the landing <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-46">snap position</a>.
<dt><dfn class="css" data-dfn-for="scroll-snap-stop" data-dfn-type="value" data-export="" id="valdef-scroll-snap-stop-always">always<a class="self-link" href="#valdef-scroll-snap-stop-always"></a></dfn>
<dd>
A <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-47">snap position</a> defined by this element,
when encountered by an <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-4">inertial scroll</a>,
absorbs all remaining inertia from an <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-5">inertial scroll</a>,
forcing a stop at this <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-48">snap position</a>,
exactly as if the scroll had enough inertia to reach the <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-49">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" data-link-type="propdesc" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop-2">scroll-snap-stop: always</a>,
an inertial scroll can only move one <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-50">snap position</a> per inertial scroll action.</p>
</dl>
<h2 class="heading settled" data-level="7" id="snap-concepts"><span class="secno">7. </span><span class="content">Snapping Mechanics</span><a class="self-link" href="#snap-concepts"></a></h2>
<p>The precise model algorithm to select a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position-51">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" data-level="7.1" 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 data-md="">
<p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" data-local-lt="explicit" data-lt="explicit scroll" id="explicit-scroll">explicit scrolling</dfn></p>
<dd data-md="">
<p>A scroll is <a data-link-type="dfn" href="#explicit-scroll" id="ref-for-explicit-scroll-2">explicit</a> if it has an intended end position,
but no intended direction.</p>
<p>This includes methods such as:</p>
<ul>
<li data-md="">
<p>a panning gesture,
released without momentum</p>
<li data-md="">
<p>manipulating the scrollbar "thumb" explicitly</p>
<li data-md="">
<p>programmatically scrolling via APIs such as <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto">scrollTo()</a></code></p>
<li data-md="">
<p>tabbing through the document’s focusable elements</p>
<li data-md="">
<p>navigating to an anchor within the page</p>
</ul>
<dt data-md="">
<p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" data-local-lt="inertial" data-lt="inertial scroll" id="inertial-scroll">inertial scrolling</dfn></p>
<dd data-md="">
<p>A scroll is <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-6">inertial</a> if it has both an intended end position
and an intended direction.</p>
<p>This includes methods such as:</p>
<ul>
<li data-md="">
<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 data-md="">
<p>a mousewheel scroll</p>
<li data-md="">
<p>programmatically scrolling via APIs such as <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollby">scrollBy()</a></code></p>
</ul>
<p>The scroll position that an <a data-link-type="dfn" href="#inertial-scroll" id="ref-for-inertial-scroll-7">inertial</a> scroll would naturally land on
without further intervention is the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="natural-end-point">natural end-point</dfn>.</p>
<dt data-md="">
<p><dfn class="dfn-paneled" data-dfn-type="dfn" data-export="" data-local-lt="directional" data-lt="directional scroll" id="directional-scroll">directional scrolling</dfn></p>
<dd data-md="">
<p>A scroll is <a data-link-type="dfn" href="#directional-scroll" id="ref-for-directional-scroll-1">directional</a> if it has an intended direction,
but no intended end point.</p>
<p>This includes methods such as:</p>
<ul>
<li data-md="">
<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 class="dfn-paneled" data-dfn-type="dfn" data-export="" id="axis-lock">axis-lock</dfn> a scroll when its direction
is sufficiently vertical or horizontal.
An <a data-link-type="dfn" href="#axis-lock" id="ref-for-axis-lock-1">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>
<h3 class="heading settled" data-level="7.2" 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></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