CINXE.COM
CSS Scroll Snap Module Level 1
<!doctype html><html lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"> <title>CSS Scroll Snap Module Level 1</title> <meta content="ED" name="w3c-status"> <link href="https://www.w3.org/StyleSheets/TR/2021/W3C-ED" rel="stylesheet"> <meta content="Bikeshed version 742f3d674, updated Mon Nov 4 14:56:54 2024 -0800" name="generator"> <link href="https://www.w3.org/TR/css-scroll-snap-1/" rel="canonical"> <link href="https://drafts.csswg.org/csslogo.ico" rel="icon"> <meta content="634ecfb8988b4f0dfab0ada6947af660bd6cbe33" name="revision"> <meta content="dark light" name="color-scheme"> <link href="https://www.w3.org/StyleSheets/TR/2021/dark.css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css"> <style> pre.ascii-art { display: table; /* shrinkwrap */ margin: 1em auto; line-height: normal; } </style> <style>/* Boilerplate: style-autolinks */ .css.css, .property.property, .descriptor.descriptor { color: var(--a-normal-text); 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; } @media (prefers-color-scheme: dark) { :root { --selflink-text: black; --selflink-bg: silver; --selflink-hover-text: white; } } </style> <style>/* Boilerplate: style-colors */ /* Any --*-text not paired with a --*-bg is assumed to have a transparent bg */ :root { color-scheme: light dark; --text: black; --bg: white; --unofficial-watermark: url(https://www.w3.org/StyleSheets/TR/2016/logos/UD-watermark); --logo-bg: #1a5e9a; --logo-active-bg: #c00; --logo-text: white; --tocnav-normal-text: #707070; --tocnav-normal-bg: var(--bg); --tocnav-hover-text: var(--tocnav-normal-text); --tocnav-hover-bg: #f8f8f8; --tocnav-active-text: #c00; --tocnav-active-bg: var(--tocnav-normal-bg); --tocsidebar-text: var(--text); --tocsidebar-bg: #f7f8f9; --tocsidebar-shadow: rgba(0,0,0,.1); --tocsidebar-heading-text: hsla(203,20%,40%,.7); --toclink-text: var(--text); --toclink-underline: #3980b5; --toclink-visited-text: var(--toclink-text); --toclink-visited-underline: #054572; --heading-text: #005a9c; --hr-text: var(--text); --algo-border: #def; --del-text: red; --del-bg: transparent; --ins-text: #080; --ins-bg: transparent; --a-normal-text: #034575; --a-normal-underline: #bbb; --a-visited-text: var(--a-normal-text); --a-visited-underline: #707070; --a-hover-bg: rgba(75%, 75%, 75%, .25); --a-active-text: #c00; --a-active-underline: #c00; --blockquote-border: silver; --blockquote-bg: transparent; --blockquote-text: currentcolor; --issue-border: #e05252; --issue-bg: #fbe9e9; --issue-text: var(--text); --issueheading-text: #831616; --example-border: #e0cb52; --example-bg: #fcfaee; --example-text: var(--text); --exampleheading-text: #574b0f; --note-border: #52e052; --note-bg: #e9fbe9; --note-text: var(--text); --noteheading-text: hsl(120, 70%, 30%); --notesummary-underline: silver; --assertion-border: #aaa; --assertion-bg: #eee; --assertion-text: black; --advisement-border: orange; --advisement-bg: #fec; --advisement-text: var(--text); --advisementheading-text: #b35f00; --warning-border: red; --warning-bg: hsla(40,100%,50%,0.95); --warning-text: var(--text); --amendment-border: #330099; --amendment-bg: #F5F0FF; --amendment-text: var(--text); --amendmentheading-text: #220066; --def-border: #8ccbf2; --def-bg: #def; --def-text: var(--text); --defrow-border: #bbd7e9; --datacell-border: silver; --indexinfo-text: #707070; --indextable-hover-text: black; --indextable-hover-bg: #f7f8f9; --outdatedspec-bg: rgba(0, 0, 0, .5); --outdatedspec-text: black; --outdated-bg: maroon; --outdated-text: white; --outdated-shadow: red; --editedrec-bg: darkorange; } @media (prefers-color-scheme: dark) { :root { --text: #ddd; --bg: black; --unofficial-watermark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cg fill='%23100808' transform='translate(200 200) rotate(-45) translate(-200 -200)' stroke='%23100808' stroke-width='3'%3E%3Ctext x='50%25' y='220' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EUNOFFICIAL%3C/text%3E%3Ctext x='50%25' y='305' style='font: bold 70px sans-serif; text-anchor: middle; letter-spacing: 6px;'%3EDRAFT%3C/text%3E%3C/g%3E%3C/svg%3E"); --logo-bg: #1a5e9a; --logo-active-bg: #c00; --logo-text: white; --tocnav-normal-text: #999; --tocnav-normal-bg: var(--bg); --tocnav-hover-text: var(--tocnav-normal-text); --tocnav-hover-bg: #080808; --tocnav-active-text: #f44; --tocnav-active-bg: var(--tocnav-normal-bg); --tocsidebar-text: var(--text); --tocsidebar-bg: #080808; --tocsidebar-shadow: rgba(255,255,255,.1); --tocsidebar-heading-text: hsla(203,20%,40%,.7); --toclink-text: var(--text); --toclink-underline: #6af; --toclink-visited-text: var(--toclink-text); --toclink-visited-underline: #054572; --heading-text: #8af; --hr-text: var(--text); --algo-border: #456; --del-text: #f44; --del-bg: transparent; --ins-text: #4a4; --ins-bg: transparent; --a-normal-text: #6af; --a-normal-underline: #555; --a-visited-text: var(--a-normal-text); --a-visited-underline: var(--a-normal-underline); --a-hover-bg: rgba(25%, 25%, 25%, .2); --a-active-text: #f44; --a-active-underline: var(--a-active-text); --borderedblock-bg: rgba(255, 255, 255, .05); --blockquote-border: silver; --blockquote-bg: var(--borderedblock-bg); --blockquote-text: currentcolor; --issue-border: #e05252; --issue-bg: var(--borderedblock-bg); --issue-text: var(--text); --issueheading-text: hsl(0deg, 70%, 70%); --example-border: hsl(50deg, 90%, 60%); --example-bg: var(--borderedblock-bg); --example-text: var(--text); --exampleheading-text: hsl(50deg, 70%, 70%); --note-border: hsl(120deg, 100%, 35%); --note-bg: var(--borderedblock-bg); --note-text: var(--text); --noteheading-text: hsl(120, 70%, 70%); --notesummary-underline: silver; --assertion-border: #444; --assertion-bg: var(--borderedblock-bg); --assertion-text: var(--text); --advisement-border: orange; --advisement-bg: #222218; --advisement-text: var(--text); --advisementheading-text: #f84; --warning-border: red; --warning-bg: hsla(40,100%,20%,0.95); --warning-text: var(--text); --amendment-border: #330099; --amendment-bg: #080010; --amendment-text: var(--text); --amendmentheading-text: #cc00ff; --def-border: #8ccbf2; --def-bg: #080818; --def-text: var(--text); --defrow-border: #136; --datacell-border: silver; --indexinfo-text: #aaa; --indextable-hover-text: var(--text); --indextable-hover-bg: #181818; --outdatedspec-bg: rgba(255, 255, 255, .5); --outdatedspec-text: black; --outdated-bg: maroon; --outdated-text: white; --outdated-shadow: red; --editedrec-bg: darkorange; } /* In case a transparent-bg image doesn't expect to be on a dark bg, which is quite common in practice... */ img { background: white; } } </style> <style>/* Boilerplate: 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); } figcaption { counter-increment: figure; } figcaption:not(.no-marker)::before { content: "Figure " counter(figure) " "; } </style> <style>/* Boilerplate: style-dfn-panel */ :root { --dfnpanel-bg: #ddd; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #ffc; --dfnpanel-target-outline: orange; } @media (prefers-color-scheme: dark) { :root { --dfnpanel-bg: #222; --dfnpanel-text: var(--text); --dfnpanel-target-bg: #333; --dfnpanel-target-outline: silver; } } .dfn-panel { position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.75em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--dfnpanel-bg); color: var(--dfnpanel-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .dfn-panel:not(.on) { display: none; } .dfn-panel * { margin: 0; padding: 0; text-indent: 0; } .dfn-panel > b { display: block; } .dfn-panel a { color: var(--dfnpanel-text); } .dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; } .dfn-panel a:focus { outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color; } .dfn-panel > b + b { margin-top: 0.25em; } .dfn-panel ul { padding: 0 0 0 1em; list-style: none; } .dfn-panel li a { max-width: calc(300px - 1.5em - 1em); overflow: hidden; text-overflow: ellipsis; } .dfn-panel.activated { display: inline-block; position: fixed; left: 8px; bottom: 2em; margin: 0 auto; max-width: calc(100vw - 1.5em - .4em - .5em); max-height: 30vh; transition: left 1s ease-out, bottom 1s ease-out; } .dfn-panel .link-item:hover { text-decoration: underline; } .dfn-panel .link-item .copy-icon { opacity: 0; } .dfn-panel .link-item:hover .copy-icon, .dfn-panel .link-item .copy-icon:focus { opacity: 1; } .dfn-panel .copy-icon { display: inline-block; margin-right: 0.5em; width: 0.85em; height: 1em; border-radius: 3px; background-color: #ccc; cursor: pointer; } .dfn-panel .copy-icon .icon { width: 100%; height: 100%; background-color: #fff; display: flex; justify-content: center; align-items: center; position: relative; } .dfn-panel .copy-icon .icon::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 1px solid black; background-color: #ccc; opacity: 0.25; transform: translate(3px, -3px); } .dfn-panel .copy-icon:active .icon::before { opacity: 1; } .dfn-paneled[role="button"] { cursor: help; } .highlighted { animation: target-fade 3s; } @keyframes target-fade { from { background-color: var(--dfnpanel-target-bg); outline: 5px solid var(--dfnpanel-target-outline); } to { color: var(--a-normal-text); background-color: transparent; outline: transparent; } } </style> <style>/* Boilerplate: style-issues */ a[href].issue-return { float: right; float: inline-end; color: var(--issueheading-text); font-weight: bold; text-decoration: none; } </style> <style>/* Boilerplate: 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>/* Boilerplate: style-mdn-anno */ :root { --mdn-bg: #EEE; --mdn-shadow: #999; --mdn-nosupport-text: #ccc; --mdn-pass: green; --mdn-fail: red; } @media (prefers-color-scheme: dark) { :root { --mdn-bg: #222; --mdn-shadow: #444; --mdn-nosupport-text: #666; --mdn-pass: #690; --mdn-fail: #d22; } } .mdn-anno { background: var(--mdn-bg, #EEE); border-radius: .25em; box-shadow: 0 0 3px var(--mdn-shadow, #999); color: var(--text, black); font: 1em sans-serif; hyphens: none; max-width: min-content; overflow: hidden; padding: 0.2em; position: absolute; right: 0.3em; top: auto; white-space: nowrap; word-wrap: normal; z-index: 8; } .mdn-anno.unpositioned { display: none; } .mdn-anno.overlapping-main { opacity: .2; transition: opacity .1s; } .mdn-anno[open] { opacity: 1; z-index: 9; min-width: 9em; } .mdn-anno:hover { opacity: 1; outline: var(--text, black) 1px solid; } .mdn-anno > summary { font-weight: normal; text-align: right; cursor: pointer; display: block; } .mdn-anno > summary > .less-than-two-engines-flag { color: var(--mdn-fail); padding-right: 2px; } .mdn-anno > summary > .all-engines-flag { color: var(--mdn-pass); padding-right: 2px; } .mdn-anno > summary > span { color: #fff; background-color: #000; font-weight: normal; font-family: zillaslab, Palatino, "Palatino Linotype", serif; padding: 2px 3px 0px 3px; line-height: 1.3em; vertical-align: top; } .mdn-anno > .feature { margin-top: 20px; } .mdn-anno > .feature:not(:first-of-type) { border-top: 1px solid #999; margin-top: 6px; padding-top: 2px; } .mdn-anno > .feature > .less-than-two-engines-text { color: var(--mdn-fail); } .mdn-anno > .feature > .all-engines-text { color: var(--mdn-pass); } .mdn-anno > .feature > p { font-size: .75em; margin-top: 6px; margin-bottom: 0; } .mdn-anno > .feature > p + p { margin-top: 3px; } .mdn-anno > .feature > .support { display: block; font-size: 0.6em; margin: 0; padding: 0; margin-top: 2px; } .mdn-anno > .feature > .support + div { padding-top: 0.5em; } .mdn-anno > .feature > .support > hr { display: block; border: none; border-top: 1px dotted #999; padding: 3px 0px 0px 0px; margin: 2px 3px 0px 3px; } .mdn-anno > .feature > .support > hr::before { content: ""; } .mdn-anno > .feature > .support > span { padding: 0.2em 0; display: block; display: table; } .mdn-anno > .feature > .support > span.no { color: var(--mdn-nosupport-text); filter: grayscale(100%); } .mdn-anno > .feature > .support > span.no::before { opacity: 0.5; } .mdn-anno > .feature > .support > span:first-of-type { padding-top: 0.5em; } .mdn-anno > .feature > .support > span > span { padding: 0 0.5em; display: table-cell; } .mdn-anno > .feature > .support > span > span:first-child { width: 100%; } .mdn-anno > .feature > .support > span > span:last-child { width: 100%; white-space: pre; padding: 0; } .mdn-anno > .feature > .support > span::before { content: ' '; display: table-cell; min-width: 1.5em; height: 1.5em; background: no-repeat center center; background-size: contain; text-align: right; font-size: 0.75em; font-weight: bold; } .mdn-anno > .feature > .support > .chrome_android::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); } .mdn-anno > .feature > .support > .firefox_android::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); } .mdn-anno > .feature > .support > .chrome::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); } .mdn-anno > .feature > .support > .edge_blink::before { background-image: url(https://resources.whatwg.org/browser-logos/edge.svg); } .mdn-anno > .feature > .support > .edge::before { background-image: url(https://resources.whatwg.org/browser-logos/edge_legacy.svg); } .mdn-anno > .feature > .support > .firefox::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); } .mdn-anno > .feature > .support > .ie::before { background-image: url(https://resources.whatwg.org/browser-logos/ie.png); } .mdn-anno > .feature > .support > .safari_ios::before { background-image: url(https://resources.whatwg.org/browser-logos/safari-ios.svg); } .mdn-anno > .feature > .support > .nodejs::before { background-image: url(https://nodejs.org/static/images/favicons/favicon.ico); } .mdn-anno > .feature > .support > .opera_android::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.svg); } .mdn-anno > .feature > .support > .opera::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.svg); } .mdn-anno > .feature > .support > .safari::before { background-image: url(https://resources.whatwg.org/browser-logos/safari.png); } .mdn-anno > .feature > .support > .samsunginternet_android::before { background-image: url(https://resources.whatwg.org/browser-logos/samsung.svg); } .mdn-anno > .feature > .support > .webview_android::before { background-image: url(https://resources.whatwg.org/browser-logos/android-webview.png); } .name-slug-mismatch { color: red; } .caniuse-status:hover { z-index: 9; } /* dt, li, .issue, .note, and .example are "position: relative", so to put annotation at right margin, must move to right of containing block */; .h-entry:not(.status-LS) dt > .mdn-anno, .h-entry:not(.status-LS) li > .mdn-anno, .h-entry:not(.status-LS) .issue > .mdn-anno, .h-entry:not(.status-LS) .note > .mdn-anno, .h-entry:not(.status-LS) .example > .mdn-anno { right: -6.7em; } .h-entry p + .mdn-anno { margin-top: 0; } h2 + .mdn-anno.after { margin: -48px 0 0 0; } h3 + .mdn-anno.after { margin: -46px 0 0 0; } h4 + .mdn-anno.after { margin: -42px 0 0 0; } h5 + .mdn-anno.after { margin: -40px 0 0 0; } h6 + .mdn-anno.after { margin: -40px 0 0 0; } </style> <style>/* Boilerplate: style-ref-hints */ :root { --ref-hint-bg: #ddd; --ref-hint-text: var(--text); } @media (prefers-color-scheme: dark) { :root { --ref-hint-bg: #222; --ref-hint-text: var(--text); } } .ref-hint { display: inline-block; position: absolute; z-index: 35; width: 20em; width: 300px; height: auto; max-height: 500px; overflow: auto; padding: 0.5em 0.5em; font: small Helvetica Neue, sans-serif, Droid Sans Fallback; background: var(--ref-hint-bg); color: var(--ref-hint-text); border: outset 0.2em; white-space: normal; /* in case it's moved into a pre */ } .ref-hint * { margin: 0; padding: 0; text-indent: 0; } .ref-hint ul { padding: 0 0 0 1em; list-style: none; } </style> <style>/* Boilerplate: style-selflinks */ :root { --selflink-text: white; --selflink-bg: gray; --selflink-hover-text: black; } .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%; } .example > a.self-link, .note > a.self-link, .issue > a.self-link { /* These blocks are overflow:auto, so positioning outside doesn't work. */ left: auto; right: 0; } 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: var(--selflink-bg); color: var(--selflink-text); font-style: normal; transition: opacity .2s, background-color .2s, color .2s; } dfn:hover > a.self-link { opacity: 1; } dfn > a.self-link:hover { color: var(--selflink-hover-text); } a.self-link::before { content: "¶"; } .heading > a.self-link::before { content: "§"; } dfn > a.self-link::before { content: "#"; } </style> <style>/* Boilerplate: style-syntax-highlighting */ 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:not(.idl) { background: rgba(0, 0, 0, .03); } c-[a] { color: #990055 } /* Keyword.Declaration */ c-[b] { color: #990055 } /* Keyword.Type */ c-[c] { color: #708090 } /* Comment */ c-[d] { color: #708090 } /* Comment.Multiline */ c-[e] { color: #0077aa } /* Name.Attribute */ c-[f] { color: #669900 } /* Name.Tag */ c-[g] { color: #222222 } /* Name.Variable */ c-[k] { color: #990055 } /* Keyword */ c-[l] { color: #000000 } /* Literal */ c-[m] { color: #000000 } /* Literal.Number */ c-[n] { color: #0077aa } /* Name */ c-[o] { color: #999999 } /* Operator */ c-[p] { color: #999999 } /* Punctuation */ c-[s] { color: #a67f59 } /* Literal.String */ c-[t] { color: #a67f59 } /* Literal.String.Single */ c-[u] { color: #a67f59 } /* Literal.String.Double */ c-[cp] { color: #708090 } /* Comment.Preproc */ c-[c1] { color: #708090 } /* Comment.Single */ c-[cs] { color: #708090 } /* Comment.Special */ c-[kc] { color: #990055 } /* Keyword.Constant */ c-[kn] { color: #990055 } /* Keyword.Namespace */ c-[kp] { color: #990055 } /* Keyword.Pseudo */ c-[kr] { color: #990055 } /* Keyword.Reserved */ c-[ld] { color: #000000 } /* Literal.Date */ c-[nc] { color: #0077aa } /* Name.Class */ c-[no] { color: #0077aa } /* Name.Constant */ c-[nd] { color: #0077aa } /* Name.Decorator */ c-[ni] { color: #0077aa } /* Name.Entity */ c-[ne] { color: #0077aa } /* Name.Exception */ c-[nf] { color: #0077aa } /* Name.Function */ c-[nl] { color: #0077aa } /* Name.Label */ c-[nn] { color: #0077aa } /* Name.Namespace */ c-[py] { color: #0077aa } /* Name.Property */ c-[ow] { color: #999999 } /* Operator.Word */ c-[mb] { color: #000000 } /* Literal.Number.Bin */ c-[mf] { color: #000000 } /* Literal.Number.Float */ c-[mh] { color: #000000 } /* Literal.Number.Hex */ c-[mi] { color: #000000 } /* Literal.Number.Integer */ c-[mo] { color: #000000 } /* Literal.Number.Oct */ c-[sb] { color: #a67f59 } /* Literal.String.Backtick */ c-[sc] { color: #a67f59 } /* Literal.String.Char */ c-[sd] { color: #a67f59 } /* Literal.String.Doc */ c-[se] { color: #a67f59 } /* Literal.String.Escape */ c-[sh] { color: #a67f59 } /* Literal.String.Heredoc */ c-[si] { color: #a67f59 } /* Literal.String.Interpol */ c-[sx] { color: #a67f59 } /* Literal.String.Other */ c-[sr] { color: #a67f59 } /* Literal.String.Regex */ c-[ss] { color: #a67f59 } /* Literal.String.Symbol */ c-[vc] { color: #0077aa } /* Name.Variable.Class */ c-[vg] { color: #0077aa } /* Name.Variable.Global */ c-[vi] { color: #0077aa } /* Name.Variable.Instance */ c-[il] { color: #000000 } /* Literal.Number.Integer.Long */ @media (prefers-color-scheme: dark) { .highlight:not(.idl) { background: rgba(255, 255, 255, .05); } c-[a] { color: #d33682 } /* Keyword.Declaration */ c-[b] { color: #d33682 } /* Keyword.Type */ c-[c] { color: #2aa198 } /* Comment */ c-[d] { color: #2aa198 } /* Comment.Multiline */ c-[e] { color: #268bd2 } /* Name.Attribute */ c-[f] { color: #b58900 } /* Name.Tag */ c-[g] { color: #cb4b16 } /* Name.Variable */ c-[k] { color: #d33682 } /* Keyword */ c-[l] { color: #657b83 } /* Literal */ c-[m] { color: #657b83 } /* Literal.Number */ c-[n] { color: #268bd2 } /* Name */ c-[o] { color: #657b83 } /* Operator */ c-[p] { color: #657b83 } /* Punctuation */ c-[s] { color: #6c71c4 } /* Literal.String */ c-[t] { color: #6c71c4 } /* Literal.String.Single */ c-[u] { color: #6c71c4 } /* Literal.String.Double */ c-[ch] { color: #2aa198 } /* Comment.Hashbang */ c-[cp] { color: #2aa198 } /* Comment.Preproc */ c-[cpf] { color: #2aa198 } /* Comment.PreprocFile */ c-[c1] { color: #2aa198 } /* Comment.Single */ c-[cs] { color: #2aa198 } /* Comment.Special */ c-[kc] { color: #d33682 } /* Keyword.Constant */ c-[kn] { color: #d33682 } /* Keyword.Namespace */ c-[kp] { color: #d33682 } /* Keyword.Pseudo */ c-[kr] { color: #d33682 } /* Keyword.Reserved */ c-[ld] { color: #657b83 } /* Literal.Date */ c-[nc] { color: #268bd2 } /* Name.Class */ c-[no] { color: #268bd2 } /* Name.Constant */ c-[nd] { color: #268bd2 } /* Name.Decorator */ c-[ni] { color: #268bd2 } /* Name.Entity */ c-[ne] { color: #268bd2 } /* Name.Exception */ c-[nf] { color: #268bd2 } /* Name.Function */ c-[nl] { color: #268bd2 } /* Name.Label */ c-[nn] { color: #268bd2 } /* Name.Namespace */ c-[py] { color: #268bd2 } /* Name.Property */ c-[ow] { color: #657b83 } /* Operator.Word */ c-[mb] { color: #657b83 } /* Literal.Number.Bin */ c-[mf] { color: #657b83 } /* Literal.Number.Float */ c-[mh] { color: #657b83 } /* Literal.Number.Hex */ c-[mi] { color: #657b83 } /* Literal.Number.Integer */ c-[mo] { color: #657b83 } /* Literal.Number.Oct */ c-[sa] { color: #6c71c4 } /* Literal.String.Affix */ c-[sb] { color: #6c71c4 } /* Literal.String.Backtick */ c-[sc] { color: #6c71c4 } /* Literal.String.Char */ c-[dl] { color: #6c71c4 } /* Literal.String.Delimiter */ c-[sd] { color: #6c71c4 } /* Literal.String.Doc */ c-[se] { color: #6c71c4 } /* Literal.String.Escape */ c-[sh] { color: #6c71c4 } /* Literal.String.Heredoc */ c-[si] { color: #6c71c4 } /* Literal.String.Interpol */ c-[sx] { color: #6c71c4 } /* Literal.String.Other */ c-[sr] { color: #6c71c4 } /* Literal.String.Regex */ c-[ss] { color: #6c71c4 } /* Literal.String.Symbol */ c-[fm] { color: #268bd2 } /* Name.Function.Magic */ c-[vc] { color: #cb4b16 } /* Name.Variable.Class */ c-[vg] { color: #cb4b16 } /* Name.Variable.Global */ c-[vi] { color: #cb4b16 } /* Name.Variable.Instance */ c-[vm] { color: #cb4b16 } /* Name.Variable.Magic */ c-[il] { color: #657b83 } /* Literal.Number.Integer.Long */ } </style> <style>/* Boilerplate: style-wpt */ :root { --wpt-border: hsl(0, 0%, 60%); --wpt-bg: hsl(0, 0%, 95%); --wpt-text: var(--text); --wptheading-text: hsl(0, 0%, 30%); } @media (prefers-color-scheme: dark) { :root { --wpt-border: hsl(0, 0%, 30%); --wpt-bg: var(--borderedblock-bg); --wpt-text: var(--text); --wptheading-text: hsl(0, 0%, 60%); } } .wpt-tests-block { list-style: none; border-left: .5em solid var(--wpt-border); background: var(--wpt-bg); color: var(--wpt-text); margin: 1em auto; padding: .5em; } .wpt-tests-block summary { color: var(--wptheading-text); font-weight: normal; text-transform: uppercase; } .wpt-tests-block summary::marker{ color: var(--wpt-border); } .wpt-tests-block summary:hover::marker{ color: var(--wpt-text); } /* The only content of a wpt test block in its closed state is the <summary>, which contains the word TESTS, and that is absolutely positioned. In that closed state, wpt test blocks are styled to have a top margin whose height is exactly equal to the height of the absolutely positioned <summary>, and no other background/padding/margin/border. The wpt test block elements will therefore allow the maring of the previous/next block elements to collapse through them; if this combined margin would be larger than its own top margin, it stays as is, and therefore the pre-existing vertical rhythm of the document is undisturbed. If that combined margin would be smaller, it is grown to that size. This means that the wpt test block ensures that there's always enough vertical space to insert the summary, without adding more than is needed. */ .wpt-tests-block:not([open]){ padding: 0; border: none; background: none; font-size: 0.75em; line-height: 1; position: relative; margin: 1em 0 0; } .wpt-tests-block:not([open]) summary { position: absolute; right: 0; bottom: 0; } /* It is possible that both the last child of a block element and the block element itself would be annotated with a <wpt> block each. If the block element has a padding or a border, that's fine, but otherwise the bottom margin of the block and of its last child would collapse and both <wpt> elements would overlap, being both placed there. To avoid that, add 1px of padding to the <wpt> element annotating the last child to prevent the bottom margin of the block and of its last child from collapsing (and as much negative margin, as wel only want to prevent margin collapsing, but are not trying to actually take more space). */ .wpt-tests-block:not([open]):last-child { padding-bottom: 1px; margin-bottom: -1px; } /* Exception to the previous rule: don't do that in non-last list items, because it's not necessary, and would therefore consume more space than strictly needed. Lists must have list items as children, not <wpt> elements, so a <wpt> element cannot be a sibling of a list item, and the collision that the previous rule avoids cannot happen. */ li:not(:last-child) > .wpt-tests-block:not([open]):last-child, dd:not(:last-child) > .wpt-tests-block:not([open]):last-child { padding-bottom: 0; margin-bottom: 0; } .wpt-tests-block:not([open]):not(:hover){ opacity: 0.5; } .wpt-tests-list { list-style: none; display: grid; margin: 0; padding: 0; grid-template-columns: 1fr max-content auto auto; grid-column-gap: .5em; } .wpt-tests-block hr:last-child { display: none; } .wpt-test { display: contents; } .wpt-test > a { text-decoration: underline; border: none; } .wpt-test > .wpt-name { grid-column: 1; } .wpt-test > .wpt-results { grid-column: 2; } .wpt-test > .wpt-live { grid-column: 3; } .wpt-test > .wpt-source { grid-column: 4; } .wpt-test > .wpt-results { display: flex; gap: .1em; } .wpt-test .wpt-result { display: inline-block; height: 1em; width: 1em; border-radius: 50%; position: relative; } </style> <body class="h-entry"> <div class="head"> <p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p> <h1 class="p-name no-ref" id="title">CSS Scroll Snap Module Level 1</h1> <p id="w3c-state"><a href="https://www.w3.org/standards/types/#ED">Editor’s Draft</a>, <time class="dt-updated" datetime="2024-04-11">11 April 2024</time></p> <details open> <summary>More details about this document</summary> <div data-fill-with="spec-metadata"> <dl> <dt>This version: <dd><a class="u-url" href="https://drafts.csswg.org/css-scroll-snap-1/">https://drafts.csswg.org/css-scroll-snap-1/</a> <dt>Latest published version: <dd><a href="https://www.w3.org/TR/css-scroll-snap-1/">https://www.w3.org/TR/css-scroll-snap-1/</a> <dt>Previous Versions: <dd><a href="https://www.w3.org/TR/2021/CR-css-scroll-snap-1-20210311/" rel="prev">https://www.w3.org/TR/2021/CR-css-scroll-snap-1-20210311/</a> <dd><a href="https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/" rel="prev">https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/</a> <dd><a href="https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190131/" rel="prev">https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190131/</a> <dd><a href="https://www.w3.org/TR/2018/CR-css-scroll-snap-1-20180814/" rel="prev">https://www.w3.org/TR/2018/CR-css-scroll-snap-1-20180814/</a> <dd><a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20171214/" rel="prev">https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20171214/</a> <dd><a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20170824/" rel="prev">https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20170824/</a> <dd><a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20170209/" rel="prev">https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20170209/</a> <dd><a href="https://www.w3.org/TR/2016/CR-css-scroll-snap-1-20161020/" rel="prev">https://www.w3.org/TR/2016/CR-css-scroll-snap-1-20161020/</a> <dd><a href="https://www.w3.org/TR/2016/WD-css-scroll-snap-1-20160623/" rel="prev">https://www.w3.org/TR/2016/WD-css-scroll-snap-1-20160623/</a> <dd><a href="https://www.w3.org/TR/2016/WD-css-snappoints-1-20160329/" rel="prev">https://www.w3.org/TR/2016/WD-css-snappoints-1-20160329/</a> <dd><a href="https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/" rel="prev">https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/</a> <dt>Implementation Report: <dd><a href="https://wpt.fyi/results/css/css-scroll-snap">https://wpt.fyi/results/css/css-scroll-snap</a> <dt>Feedback: <dd><a href="https://github.com/w3c/csswg-drafts/labels/css-scroll-snap-1">CSSWG Issues Repository</a> <dt class="editor">Editors: <dd class="editor p-author h-card vcard" data-editor-id="62267"><span class="p-name fn">Matt Rakow</span> (<span class="p-org org">Microsoft</span>) <dd class="editor p-author h-card vcard" data-editor-id="45616"><span class="p-name fn">Jacob Rossi</span> (<span class="p-org org">Microsoft</span>) <dd class="editor p-author h-card vcard" data-editor-id="42199"><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" data-editor-id="35400"><a class="p-name fn u-url url" href="http://fantasai.inkedblade.net/contact">Elika J. Etemad / fantasai</a> (<span class="p-org org">Apple</span>) <dt>Suggest an Edit for this Spec: <dd><a href="https://github.com/w3c/csswg-drafts/blob/main/css-scroll-snap-1/Overview.bs">GitHub Editor</a> </dl> </div> </details> <div data-fill-with="warning"></div> <p class="copyright" data-fill-with="copyright"><a href="https://www.w3.org/policies/#copyright">Copyright</a> © 2024 <a href="https://www.w3.org/">World Wide Web Consortium</a>. <abbr title="World Wide Web Consortium">W3C</abbr><sup>®</sup> <a href="https://www.w3.org/policies/#Legal_Disclaimer">liability</a>, <a href="https://www.w3.org/policies/#W3C_Trademarks">trademark</a> and <a href="https://www.w3.org/copyright/software-license/" rel="license" title="W3C Software and Document License">permissive document license</a> rules apply. </p> <hr title="Separator for header"> </div> <div class="p-summary" data-fill-with="abstract"> <h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2> <p>This module contains features to control panning and scrolling behavior with “snap positions”.</p> <a href="https://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, etc. <script> const githubPrefix = "https://w3c.github.io/csswg-drafts/"; if(location.href.slice(0, githubPrefix.length) == githubPrefix) { const suffix = location.href.slice(githubPrefix.length); const draftUrl = "https://drafts.csswg.org/" + suffix; window.location.replace(draftUrl); } </script> </div> <h2 class="no-num no-toc no-ref heading settled" id="sotd"><span class="content">Status of this document</span></h2> <div data-fill-with="status"> <p> This is a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as work in progress. </p> <p>Please send feedback by <a href="https://github.com/w3c/csswg-drafts/issues">filing issues in GitHub</a> (preferred), including the spec code “css-scroll-snap” in the title, like this: “[css-scroll-snap] <i>…summary of comment…</i>”. All issues and comments are <a href="https://lists.w3.org/Archives/Public/public-css-archive/">archived</a>. Alternately, feedback can be sent to the (<a href="https://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list <a href="mailto:www-style@w3.org?Subject=%5Bcss-scroll-snap%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>. </p> <p>This document is governed by the <a href="https://www.w3.org/policies/process/20231103/" id="w3c_process_revision">03 November 2023 W3C Process Document</a>. </p> <p></p> <p>A test suite and an implementation report will be produced during the CR period.</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="property css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop">scroll-snap-stop</a> <li>whether <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type">scroll-snap-type</a> can cause boxes that are not <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container">scroll containers</a> to <a data-link-type="dfn" href="#captures-snap-positions" id="ref-for-captures-snap-positions">capture snap positions</a> (see <a href="https://github.com/w3c/csswg-drafts/issues/4496">discussion</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> <ol class="toc"> <li><a href="#placement"><span class="secno">1.1</span> <span class="content">Module interactions</span></a> <li><a href="#values"><span class="secno">1.2</span> <span class="content">Value Definitions</span></a> </ol> <li><a href="#examples"><span class="secno">2</span> <span class="content">Motivating Examples</span></a> <li><a href="#overview"><span class="secno">3</span> <span class="content">Scroll Snap Model</span></a> <li> <a href="#properties-on-the-scroll-container"><span class="secno">4</span> <span class="content">Capturing Scroll Snap Areas: Properties on the scroll container</span></a> <ol class="toc"> <li> <a href="#scroll-snap-type"><span class="secno">4.1</span> <span class="content">Scroll Snapping Rules: the <span class="property">scroll-snap-type</span> property</span></a> <ol class="toc"> <li><a href="#snap-axis"><span class="secno">4.1.1</span> <span class="content"> Scroll Snap Axis: the <span class="css">x</span>, <span class="css">y</span>, <span class="css">block</span>, <span class="css">inline</span>, and <span class="css">both</span> values</span></a> <li><a href="#snap-strictness"><span class="secno">4.1.2</span> <span class="content"> Scroll Snap Strictness: the <span class="css">none</span>, <span class="css">proximity</span>, and <span class="css">mandatory</span> values</span></a> <li><a href="#re-snap"><span class="secno">4.1.3</span> <span class="content"> Re-snapping After Layout Changes</span></a> </ol> <li><a href="#scroll-padding"><span class="secno">4.2</span> <span class="content">Scroll Snapport: the <span class="property">scroll-padding</span> property</span></a> </ol> <li> <a href="#properties-on-the-elements"><span class="secno">5</span> <span class="content">Aligning Scroll Snap Areas: Properties on the elements</span></a> <ol class="toc"> <li><a href="#scroll-margin"><span class="secno">5.1</span> <span class="content">Scroll Snapping Area: the <span class="property">scroll-margin</span> property</span></a> <li> <a href="#scroll-snap-align"><span class="secno">5.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">5.2.1</span> <span class="content"> Scoping Valid Snap Positions to Visible Boxes</span></a> <li><a href="#snap-overflow"><span class="secno">5.2.2</span> <span class="content"> Snapping Boxes that Overflow the Scrollport</span></a> <li><a href="#unreachable"><span class="secno">5.2.3</span> <span class="content"> Unreachable Snap Positions</span></a> </ol> <li><a href="#scroll-snap-stop"><span class="secno">5.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">6</span> <span class="content">Snapping Mechanics</span></a> <ol class="toc"> <li><a href="#scroll-types"><span class="secno">6.1</span> <span class="content">Types of Scrolling Methods</span></a> <li> <a href="#choosing"><span class="secno">6.2</span> <span class="content">Choosing Snap Positions</span></a> <ol class="toc"> <li><a href="#multiple-aligned-snap-areas"><span class="secno">6.2.1</span> <span class="content">Selecting between multiple aligned snap areas</span></a> </ol> </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-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-padding</span></span></a> <li><a href="#margin-longhands-physical"><span class="secno"></span> <span class="content">Physical Longhands for <span class="property">scroll-margin</span></span></a> <li><a href="#margin-longhands-logical"><span class="secno"></span> <span class="content">Flow-relative Longhands for <span class="property">scroll-margin</span></span></a> </ol> <li><a href="#priv-sec"><span class="secno">7</span> <span class="content">Privacy and Security Considerations</span></a> <li><a href="#acknowledgements"><span class="secno">8</span> <span class="content">Acknowledgements</span></a> <li> <a href="#changes"><span class="secno">9</span> <span class="content">Changes</span></a> <ol class="toc"> <li><a href="#changes-20190319"><span class="secno">9.1</span> <span class="content">Changes Since 19 March 2019 CR</span></a> <li><a href="#changes-20190131"><span class="secno">9.2</span> <span class="content">Changes Since 31 January 2019 CR</span></a> <li><a href="#changes-20180814"><span class="secno">9.3</span> <span class="content">Changes Since 14 August 2018 CR</span></a> <li><a href="#changes-20171214"><span class="secno">9.4</span> <span class="content">Changes Since 14 December 2017 CR</span></a> <li><a href="#changes-20170824"><span class="secno">9.5</span> <span class="content">Changes Since 24 August 2017 CR</span></a> <li><a href="#changes-20161020"><span class="secno">9.6</span> <span class="content">Changes Since 20 October 2016 CR</span></a> </ol> <li> <a href="#w3c-conformance"><span class="secno"></span> <span class="content"> Conformance</span></a> <ol class="toc"> <li><a href="#w3c-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a> <li><a href="#w3c-conformance-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a> <li> <a href="#w3c-partial"><span class="secno"></span> <span class="content"> Partial implementations</span></a> <ol class="toc"> <li><a href="#w3c-conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a> </ol> <li><a href="#w3c-testing"><span class="secno"></span> <span class="content"> Non-experimental implementations</span></a> </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> </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><em>This section is not normative.</em></p> <p>Popular UX paradigms for scrollable content frequently employ paging through content, or sectioning into logical divisions. This is especially true for touch interactions where it is quicker and easier for users to quickly pan through a flatly-arranged breadth of content rather than delving into a hierarchical structure through tap navigation. For example, it is easier for a user to view many photos in a photo album by panning through a photo slideshow view rather than tapping on individual photos in an album.</p> <p>However, given the imprecise nature of scrolling inputs like touch panning and mousewheel scrolling, it is difficult for web developers to guarantee a well-controlled scrolling experience, in particular creating the effect of paging through content. For instance, it is easy for a user to land at an awkward scroll position which leaves an item partially on-screen when panning.</p> <p>To this end, this module introduces <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position">scroll snap positions</a> which enforce the scroll positions that a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①">scroll container’s</a> scrollport may end at after a scrolling operation has completed.</p> <p>Also, to offer better control over paging and scroll positioning even when snapping is off, this module defines the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding">scroll-padding</a> property for use on all <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container②">scroll containers</a>, to adjust the <span id="ref-for-scroll-container③">scroll container</span>’s <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region">optimal viewing region</a> for the purpose of paging and scroll-into-view operations. Similarly the <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin">scroll-margin</a> property can be used on any box to adjust its visual area for the purpose of scroll-into-view operations.</p> <h3 class="heading settled" data-level="1.1" id="placement"><span class="secno">1.1. </span><span class="content">Module interactions</span><a class="self-link" href="#placement"></a></h3> <p>This module extends the scrolling user interface features defined in <a data-link-type="biblio" href="#biblio-css2" title="Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification">[CSS2]</a> section 11.1.</p> <p>None of the properties in this module apply to the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line" id="ref-for-selectordef-first-line">::first-line</a> and <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter" id="ref-for-selectordef-first-letter">::first-letter</a> pseudo-elements.</p> <h3 class="heading settled" data-level="1.2" id="values"><span class="secno">1.2. </span><span class="content">Value Definitions</span><a class="self-link" href="#values"></a></h3> <p>This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from <a data-link-type="biblio" href="#biblio-css2" title="Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification">[CSS2]</a> using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from <a data-link-type="biblio" href="#biblio-css-values-3" title="CSS Values and Units Module Level 3">[CSS-VALUES-3]</a>. Value types not defined in this specification are defined in CSS Values & Units <span title="CSS Values and Units Module Level 3">[CSS-VALUES-3]</span>. Combination with other CSS modules may expand the definitions of these value types.</p> <p>In addition to the property-specific values listed in their definitions, all properties defined in this specification also accept the <a data-link-type="dfn" href="https://drafts.csswg.org/css-values-4/#css-wide-keywords" id="ref-for-css-wide-keywords">CSS-wide keywords</a> as their property value. For readability they have not been repeated explicitly.</p> <h2 class="heading settled" data-level="2" id="examples"><span class="secno">2. </span><span class="content">Motivating Examples</span><a class="self-link" href="#examples"></a></h2> <div class="example" id="example-b9bef3ed"> <a class="self-link" href="#example-b9bef3ed"></a> In this example, a series of images arranged in a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④">scroll container</a> are used to build a photo gallery. In this example the <span id="ref-for-scroll-container⑤">scroll container</span> is larger than the photos contained within (such that multiple images may be seen simultaneously), and the image sizes vary. Using mandatory element-based snap positions, scrolling will always complete with an image centered in the <span id="ref-for-scroll-container⑥">scroll container’s</span> scrollport. <pre class="lang-css highlight">img <c- p>{</c-> <c- c>/* Specifies that the center of each photo</c-> <c- c> should align with the center of the scroll</c-> <c- c> container in the X axis when snapping */</c-> scroll-snap-align: none center<c- p>;</c-> <c- p>}</c-> .photoGallery <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>500</c-><c- k>px</c-><c- p>;</c-> <c- k>overflow-x</c-><c- p>:</c-> auto<c- p>;</c-> <c- k>overflow-y</c-><c- p>:</c-> hidden<c- p>;</c-> <c- k>white-space</c-><c- p>:</c-> nowrap<c- p>;</c-> <c- c>/* Requires that the scroll position always be</c-> <c- c> at a snap position when the scrolling</c-> <c- c> operation completes. */</c-> scroll-snap-type: x mandatory<c- p>;</c-> <c- p>}</c-> </pre> <pre class="lang-html highlight"><c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"photoGallery"</c-><c- p>></c-> <c- p><</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>"img1.jpg"</c-><c- p>></c-> <c- p><</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>"img2.jpg"</c-><c- p>></c-> <c- p><</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>"img3.jpg"</c-><c- p>></c-> <c- p><</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>"img4.jpg"</c-><c- p>></c-> <c- p><</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>"img5.jpg"</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </pre> <figure> <img alt height="618" src="images/element_snap_positions.png" width="2238"> <figcaption> The layout of the scroll container’s contents in the example. The snapport is represented by the red rectangle, and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is “center” in the inline (horizontal) axis, a snap position is established at each scroll position which aligns the X-center of the snapport (represented by a red dotted line) with the X-center of a snap area (represented by a yellow dotted line). </figcaption> </figure> </div> <div class="example" id="example-a6210411"> <a class="self-link" href="#example-a6210411"></a> This example builds a paginated document that aligns each page near to (but not exactly on) the edge of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑦">scroll container</a>. This allows the previous page to “peek” in from above in order to make the user aware that they are not yet at the top of the document. Using proximity snap positions instead of mandatory snap positions allows the user to stop halfway through a page (rather than forcing them to snap one page at a time). However, if a scrolling operation would finish near a snap position, then the scroll will be adjusted to align the page as specified. <pre class="lang-css highlight">.page <c- p>{</c-> <c- c>/* Defines the top of each page as the</c-> <c- c> edge that should be used for snapping */</c-> scroll-snap-align: start none<c- p>;</c-> <c- p>}</c-> .docScroller <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>500</c-><c- k>px</c-><c- p>;</c-> <c- k>overflow-x</c-><c- p>:</c-> hidden<c- p>;</c-> <c- k>overflow-y</c-><c- p>:</c-> auto<c- p>;</c-> <c- c>/* Specifies that each element’s snap area should</c-> <c- c> align with a 100px offset from the top edge. */</c-> scroll-padding: <c- m>100</c-><c- k>px</c-> <c- m>0</c-> <c- m>0</c-><c- p>;</c-> <c- c>/* Encourages scrolling to end at a snap position when the</c-> <c- c> operation completes, if it is near a snap position */</c-> scroll-snap-type: y proximity<c- p>;</c-> <c- p>}</c-> </pre> <pre class="lang-html highlight"><c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"docScroller"</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"page"</c-><c- p>></c->Page 1<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"page"</c-><c- p>></c->Page 2<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"page"</c-><c- p>></c->Page 3<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"page"</c-><c- p>></c->Page 4<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </pre> <figure> <img alt height="1118" src="images/element_snap_positions_offset.png" width="286"> <figcaption> The layout of the scroll container’s contents in the example. The snapport is represented by the red rectangle (inset from the top by 100px due to the scroll-padding), and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is “start” in the Y axis, a snap position is established at each scroll position which aligns the Y-start of the snapport (represented by a red dotted line) with the Y-start of a snap area (represented by a yellow dotted line). </figcaption> </figure> </div> <h2 class="heading settled" data-level="3" id="overview"><span class="secno">3. </span><span class="content">Scroll Snap Model</span><a class="self-link" href="#overview"></a></h2> <p>This module defines controls for <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="snap position" data-lt="scroll snap position" id="scroll-snap-position">scroll snap positions</dfn>, which are scroll positions that produce particular alignments of content within a scroll container. Using the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①">scroll-snap-type</a> property on the relevant <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑧">scroll container</a>, the author can request a particular bias for the scrollport to land on a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①">snap position</a> after scrolling operations (including programmatic scrolls such as the <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto" id="ref-for-dom-window-scrollto">scrollTo()</a></code> method).</p> <p><a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②">Snap positions</a> are specified as a particular alignment (<a class="property css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align">scroll-snap-align</a>) of an element’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area">scroll snap area</a> (its border bounding box, as modified by <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①">scroll-margin</a>) within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑨">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport">snapport</a> (its scrollport, as reduced by <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①">scroll-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" id="ref-for-alignment-subject">alignment subject</a> within an <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container" id="ref-for-alignment-container">alignment container</a>. A scroll position that satisfies the specified alignment is a <span id="ref-for-scroll-snap-position③">snap position</span>.</p> <p>The act of adjusting the scroll position of a scroll container’s scrollport such that it is aligned to a snap area is called <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="snap" data-lt="scroll snap" id="scroll-snap">snapping</dfn>, and a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⓪">scroll container</a> may be <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap">snapped</a> to a <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①">snap area</a> in each axis if its scrollport is aligned with that <span id="ref-for-scroll-snap-area②">snap area</span> in that axis and there is no active scrolling operation. When there are multiple valid snap areas, a single one is chosen for each axis when <span id="ref-for-scroll-snap①">snapping</span> according to the algorithm for <a href="#multiple-aligned-snap-areas">selecting between multiple aligned snap areas</a>. 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④">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⑤">Snap positions</a> only affect the nearest ancestor <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①①">scroll container</a> on the element’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#containing-block-chain" id="ref-for-containing-block-chain">containing block chain</a>.</p> <h2 class="heading settled" data-level="4" id="properties-on-the-scroll-container"><span class="secno">4. </span><span class="content">Capturing Scroll Snap Areas: Properties on the scroll container</span><a class="self-link" href="#properties-on-the-scroll-container"></a></h2> <h3 class="heading settled" data-level="4.1" id="scroll-snap-type"><span class="secno">4.1. </span><span class="content">Scroll Snapping Rules: the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type②">scroll-snap-type</a> property</span><a class="self-link" href="#scroll-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><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one">|</a> [ x <span id="ref-for-comb-one①">|</span> y <span id="ref-for-comb-one②">|</span> block <span id="ref-for-comb-one③">|</span> inline <span id="ref-for-comb-one④">|</span> both ] [ mandatory <span id="ref-for-comb-one⑤">|</span> proximity ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-opt" id="ref-for-mult-opt">?</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>none <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>specified keyword(s) <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>discrete </table> <p>The <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type③">scroll-snap-type</a> property specifies whether a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①②">scroll container</a> is a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container">scroll snap container</a>, how <a href="#snap-strictness">strictly</a> it <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②">snaps</a>, and <a href="#snap-axis">which axes</a> are considered. If no strictness value is specified, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-proximity" id="ref-for-valdef-scroll-snap-type-proximity">proximity</a> is assumed.</p> <div class="example" id="example-35961710"> <a class="self-link" href="#example-35961710"></a> In this example, snapping to headings is enabled in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-4/#block-axis" id="ref-for-block-axis">block axis</a> (the y axis for horizontal writing, x axis for vertical writing): <pre>html { scroll-snap-type: block; /* applied to main document scroller */ } h1, h2, h3, h4, h5, h6 { scroll-snap-align: start; /* snap to the start (top) of the viewport */ } </pre> </div> <p>UAs must apply the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type④">scroll-snap-type</a> value set on the root element to the document viewport. Note that, unlike <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow" id="ref-for-propdef-overflow">overflow</a>, <span class="property" id="ref-for-propdef-scroll-snap-type⑤">scroll-snap-type</span> values are <em>not</em> propagated from HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/sections.html#the-body-element" id="ref-for-the-body-element">body</a></code>.</p> <h4 class="heading settled" data-level="4.1.1" id="snap-axis"><span class="secno">4.1.1. </span><span class="content"> Scroll Snap Axis: the <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-x" id="ref-for-valdef-scroll-snap-type-x">x</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-y" id="ref-for-valdef-scroll-snap-type-y">y</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-block" id="ref-for-valdef-scroll-snap-type-block">block</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-inline" id="ref-for-valdef-scroll-snap-type-inline">inline</a>, and <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-both" id="ref-for-valdef-scroll-snap-type-both">both</a> values</span><a class="self-link" href="#snap-axis"></a></h4> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="axis value" data-noexport id="axis-value">axis values</dfn> specify what axis(es) are affected by <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑥">snap positions</a>, and whether <span id="ref-for-scroll-snap-position⑦">snap positions</span> are evaluated independently per axis, or together as a 2D point. 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-x">x</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①③">scroll container</a> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap③">snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑧">snap positions</a> in its horizontal axis only. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export id="valdef-scroll-snap-type-y">y</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①④">scroll container</a> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap④">snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑨">snap positions</a> in its vertical axis only. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export id="valdef-scroll-snap-type-block">block</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⑤">scroll container</a> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap⑤">snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①⓪">snap positions</a> in its block axis only. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export id="valdef-scroll-snap-type-inline">inline</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⑥">scroll container</a> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap⑥">snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①①">snap positions</a> in its inline axis only. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-type" data-dfn-type="value" data-export id="valdef-scroll-snap-type-both">both</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⑦">scroll container</a> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap⑦">snaps</a> to <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①②">snap positions</a> in both of its axes independently (potentially snapping to different elements in each axis). </dl> <h4 class="heading settled" data-level="4.1.2" id="snap-strictness"><span class="secno">4.1.2. </span><span class="content"> Scroll Snap Strictness: the <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-none" id="ref-for-valdef-scroll-snap-type-none">none</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-proximity" id="ref-for-valdef-scroll-snap-type-proximity①">proximity</a>, and <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-mandatory" id="ref-for-valdef-scroll-snap-type-mandatory">mandatory</a> values</span><a class="self-link" href="#snap-strictness"></a></h4> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="strictness value" data-noexport id="strictness-value">strictness values</dfn> (<a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-none" id="ref-for-valdef-scroll-snap-type-none①">none</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-proximity" id="ref-for-valdef-scroll-snap-type-proximity②">proximity</a>, <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-mandatory" id="ref-for-valdef-scroll-snap-type-mandatory①">mandatory</a>) specify how strictly <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①③">snap positions</a> are enforced on the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-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" id="ref-for-scroll-container①⑨">scroll container</a>, the <span id="ref-for-scroll-container②⓪">scroll container</span> must not <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap⑧">snap</a>. <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" id="ref-for-scroll-container②①">scroll container</a>, the <span id="ref-for-scroll-container②②">scroll container</span> is required to be <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap⑨">snapped</a> to a snap position when there are no active scrolling operations. If a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①④">snap position</a> exists then the scroll container must <span id="ref-for-scroll-snap①⓪">snap</span> at the termination of a scroll (if none exist then no <span id="ref-for-scroll-snap①①">snapping</span> occurs). <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" id="ref-for-scroll-container②③">scroll container</a>, the <span id="ref-for-scroll-container②④">scroll container</span> may <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①②">snap</a> to a snap position at the termination of a scroll, at the discretion of the UA given the parameters of the scroll. </dl> <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 scrollport is handled by the UA, 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></p> <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" id="ref-for-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②">none</a> for <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type⑥">scroll-snap-type</a>. If a box’s nearest <a data-link-type="dfn" href="#captures-snap-positions" id="ref-for-captures-snap-positions①">snap-position capturing</a> ancestor on its <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#containing-block-chain" id="ref-for-containing-block-chain①">containing block chain</a> is a <span id="ref-for-scroll-container②⑥">scroll container</span> with a non-<span class="css" id="ref-for-valdef-scroll-snap-type-none③">none</span> value for <span class="property" id="ref-for-propdef-scroll-snap-type⑦">scroll-snap-type</span>, 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①">scroll snap container</a>, and its <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①⑤">snap positions</a> do not trigger <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①③">snapping</a>.</p> <h4 class="heading settled dfn-paneled" data-dfn-type="dfn" data-export data-level="4.1.3" data-lt="re-snap" id="re-snap"><span class="secno">4.1.3. </span><span class="content"> Re-snapping After Layout Changes</span><a class="self-link" href="#re-snap" id="ref-for-re-snap"></a></h4> <p>If the content or layout of the document changes (e.g. content is added, moved, deleted, resized) such that the content of a <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①">snapport</a> changes, the UA must re-evaluate the resulting <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-position" id="ref-for-scroll-position">scroll position</a>, and re-snap if required. If the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container②⑦">scroll container</a> was <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①④">snapped</a> before the content change and those same <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③">snap areas</a> still exist (e.g. their associated elements were not deleted), the scroll container must be re-snapped to those same snap areas after the content change. A <span id="ref-for-scroll-snap-area④">snap area</span> can be <span id="ref-for-scroll-snap①⑤">snapped</span> in each axis, following the algorithm for <a href="#multiple-aligned-snap-areas">selecting between multiple aligned snap areas</a>. If it is not possible to snap to both (e.g. if snapping to one resulted in the other being offscreen), it must prefer the focused box, followed by the targeted box, followed by the block axis if neither box is focused or targeted.</p> <p>Scrolling required by a re-snap operation to a new or different box must behave and animate the same way as any other scroll-into-view operation, including honoring controls such as <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-scroll-behavior" id="ref-for-propdef-scroll-behavior">scroll-behavior</a>. Scrolling behavior for re-snapping to the same box as before however, is UA-defined. The UA may, for example, when snapped to the start of a section, choose not to animate the scroll to the section’s new position as content is dynamically added earlier in the document in order to create the illusion of not scrolling.</p> <div class="example" id="example-d0a2d86f"> <a class="self-link" href="#example-d0a2d86f"></a> In the following example, the log console, when initially loaded and as each message is added to the bottom, remains snapped to the bottom of the content unless the user has scrolled away from that edge: <pre class="lang-css highlight">.log <c- p>{</c-> <c- k>scroll-snap-type</c-><c- p>:</c-> y proximity<c- p>;</c-> <c- k>align-content</c-><c- p>:</c-> end<c- p>;</c-> <c- p>}</c-> .log::after <c- p>{</c-> <c- k>display</c-><c- p>:</c-> block<c- p>;</c-> <c- k>content</c-><c- p>:</c-> <c- s>""</c-><c- p>;</c-> <c- k>scroll-snap-align</c-><c- p>:</c-> end<c- p>;</c-> <c- p>}</c-> </pre> <p>The rules create a single <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area⑤">scroll snap area</a> represented by the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-pseudo-4/#selectordef-after" id="ref-for-selectordef-after">::after</a> pseudo-element, positioned at the very bottom of a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container②">scroll snap container</a>. If the user scrolls “near” the bottom, the container will snap to it. If more content is dynamically added to the container, it’ll remain snapped to it (because scroll containers are required to re-snap to the same scroll snap area if it still exists after any changes). However, if the user has scrolled to somewhere else in the logs, it won’t do anything at all.</p> </div> <h3 class="heading settled" data-level="4.2" id="scroll-padding"><span class="secno">4.2. </span><span class="content">Scroll Snapport: the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②">scroll-padding</a> property</span><a class="self-link" href="#scroll-padding"></a></h3> <table class="def propdef" data-link-for-hint="scroll-padding"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding">scroll-padding</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">[ auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑥">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage"><length-percentage [0,∞]></a> ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-num-range" id="ref-for-mult-num-range">{1,4}</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>auto <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container②⑧">scroll containers</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>relative to the corresponding dimension of the scroll container’s scrollport <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>per side, either the keyword <a class="css" data-link-type="maybe" href="#valdef-scroll-padding-auto" id="ref-for-valdef-scroll-padding-auto">auto</a> or a computed <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage①"><length-percentage></a> value <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar </table> <p>This property specifies (for all <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container②⑨">scroll containers</a>, not just <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container③">scroll snap containers</a>) offsets that define the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="optimal-viewing-region">optimal viewing region</dfn> of a scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport">scrollport</a> that are obscured by other content (such as fixed-positioned toolbars or sidebars) or simply to put more breathing room between a targeted element and the edges of the scrollport.</p> <p>The <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding③">scroll-padding</a> property is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#shorthand-property" id="ref-for-shorthand-property">shorthand property</a> that sets all of the <a href="#longhands"><span class="css">scroll-padding-*</span> longhands</a> in one declaration, assigning values to the longhands representing each side exactly as the <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-box-4/#propdef-padding" id="ref-for-propdef-padding">padding</a> property does for its longhands. Values have the following meanings:</p> <dl> <dt data-md><dfn class="dfn-paneled css" data-dfn-for="scroll-padding, scroll-padding-inline, scroll-padding-inline-start, scroll-padding-inline-end, scroll-padding-block, scroll-padding-block-start, scroll-padding-block-end" data-dfn-type="value" data-export id="valdef-scroll-padding-length-percentage-0"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage②"><length-percentage [0,∞]></a></dfn> <dd data-md> <p>Defines an inward offset from the corresponding edge of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport①">scrollport</a>. When applied to the root viewport, the offset is calculated and applied relative to the layout viewport (rather than the visual viewport) the same way as the corresponding <a data-link-type="dfn" href="https://drafts.csswg.org/css-logical-1/#inset-properties" id="ref-for-inset-properties">inset properties</a> on <a data-link-type="dfn" href="https://drafts.csswg.org/css-position-3/#fixed-position" id="ref-for-fixed-position">fixed-positioned boxes</a>; the <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region①">optimal viewing region</a> is the remaining area that intersects with the visual viewport.</p> <dt data-md><dfn class="dfn-paneled css" data-dfn-for="scroll-padding, scroll-padding-inline, scroll-padding-inline-start, scroll-padding-inline-end, scroll-padding-block, scroll-padding-block-start, scroll-padding-block-end" data-dfn-type="value" data-export id="valdef-scroll-padding-auto">auto</dfn> <dd data-md> <p>Indicates that the offset for the corresponding edge of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport②">scrollport</a> is UA-determined. This should generally default to a used length of <span class="css">0px</span>, but UAs may use heuristics to detect when a non-zero value is more appropriate.</p> <div class="example" id="example-71c18b16"><a class="self-link" href="#example-71c18b16"></a> For example, a UA could detect when a <span class="css">position:fixed</span> element is being used as an opaque unscrollable “header” that obscures the content below it, and resolve the top offset to the height of that element so that a “page down” operation (such as pressing <kbd>PgDn</kbd>) automatically scrolls by one “visible page” of content. </div> </dl> <p>These offsets reduce the region of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport③">scrollport</a> that is considered “viewable” <em>for scrolling operations</em>: they have no effect on layout, on the scroll origin or initial position, or on whether or not an element is considered actually <em>visible</em>, but should affect whether an element or the caret is considered scrolled into view (e.g. for targeting or focusing operations), and reduce the amount of scrolling for paging operations (such as using the <kbd>PgUp</kbd> and <kbd>PgDn</kbd> keys or triggering equivalent operations from the scrollbar) so that within the <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region②">optimal viewing region</a> of the <span id="ref-for-scrollport④">scrollport</span> the user sees a continuous stream of content.</p> <p>For a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container④">scroll snap container</a> this region also defines the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="snapport" id="scroll-snapport">scroll snapport</dfn>—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" id="ref-for-alignment-container①">alignment container</a> for the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area⑥">scroll snap areas</a> when calculating <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①⑥">snap positions</a>.</p> <div class="example" id="example-22bb626b"> <a class="self-link" href="#example-22bb626b"></a> In this example, <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding④">scroll-padding</a> is used to center slideshow images within the portion of the scrollport that is not obscured by a fixed-position toolbar. <pre class="lang-css highlight">html <c- p>{</c-> <c- k>overflow-x</c-><c- p>:</c-> auto<c- p>;</c-> <c- k>overflow-y</c-><c- p>:</c-> hidden<c- p>;</c-> <c- k>scroll-snap-type</c-><c- p>:</c-> x mandatory<c- p>;</c-> <c- k>scroll-padding</c-><c- p>:</c-> <c- m>0</c-> <c- m>500</c-><c- k>px</c-> <c- m>0</c-> <c- m>0</c-><c- p>;</c-> <c- p>}</c-> .toolbar <c- p>{</c-> <c- k>position</c-><c- p>:</c-> fixed<c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>100</c-><c- k>%</c-><c- p>;</c-> <c- k>width</c-><c- p>:</c-> <c- m>500</c-><c- k>px</c-><c- p>;</c-> <c- k>right</c-><c- p>:</c-> <c- m>0</c-><c- p>;</c-> <c- p>}</c-> img <c- p>{</c-> <c- k>scroll-snap-align</c-><c- p>:</c-> none center<c- p>;</c-> <c- p>}</c-> </pre> </div> <p>UAs must apply the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding⑤">scroll-padding</a> values set on the root element to the document viewport. (Note that, unlike <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow" id="ref-for-propdef-overflow①">overflow</a>, <span class="property" id="ref-for-propdef-scroll-padding⑥">scroll-padding</span> values are <em>not</em> propagated from HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/sections.html#the-body-element" id="ref-for-the-body-element①">body</a></code>.)</p> <h2 class="heading settled" data-level="5" id="properties-on-the-elements"><span class="secno">5. </span><span class="content">Aligning Scroll Snap Areas: Properties on the elements</span><a class="self-link" href="#properties-on-the-elements"></a></h2> <h3 class="heading settled" data-level="5.1" id="scroll-margin"><span class="secno">5.1. </span><span class="content">Scroll Snapping Area: the <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin②">scroll-margin</a> property</span><a class="self-link" href="#scroll-margin"></a></h3> <table class="def propdef" data-link-for-hint="scroll-margin"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin">scroll-margin</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#length-value" id="ref-for-length-value"><length></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-num-range" id="ref-for-mult-num-range①">{1,4}</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>0 <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>per side, an absolute length <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type </table> <p>This property is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#shorthand-property" id="ref-for-shorthand-property①">shorthand property</a> that sets all of the <a href="#longhands"><span class="css">scroll-margin-*</span> longhands</a> in one declaration, assigning values to the longhands representing each side exactly as the <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-box-4/#propdef-margin" id="ref-for-propdef-margin">margin</a> property does for its longhands.</p> <p>Values represent outsets defining the <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-local-lt="snap area" id="scroll-snap-area">scroll snap area</dfn> that is used for snapping this box to the snapport. The <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area⑦">scroll snap area</a> is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③⓪">scroll container’s</a> coordinate space), then adding the specified outsets.</p> <p class="note" role="note"><span class="marker">Note:</span> This ensures that the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area⑧">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" id="ref-for-scroll-container③①">scroll container’s</a> coordinate space.</p> <p>If a page is navigated to a fragment that defines a target element (one that would be matched by <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo">:target</a>, or the target of <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview">scrollIntoView()</a></code>), the UA should use the element’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area⑨">scroll snap area</a>, rather than just its border box, to determine which area of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region">scrollable overflow area</a> to bring into view, <em>even when snapping is off or not applied on this element</em>.</p> <h3 class="heading settled" data-level="5.2" id="scroll-snap-align"><span class="secno">5.2. </span><span class="content">Scroll Snapping Alignment: the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align①">scroll-snap-align</a> property</span><a class="self-link" href="#scroll-snap-align"></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><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">[ none <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one⑦">|</a> start <span id="ref-for-comb-one⑧">|</span> end <span id="ref-for-comb-one⑨">|</span> center ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-num-range" id="ref-for-mult-num-range②">{1,2}</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>none <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>two keywords <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>discrete </table> <p>The <a class="property css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align②">scroll-snap-align</a> property specifies the box’s <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①⑦">snap position</a> as an alignment of its <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①⓪">snap area</a> (as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-subject" id="ref-for-alignment-subject①">alignment subject</a>) within its <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container⑤">snap container’s</a> <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport②">snapport</a> (as the <a data-link-type="dfn" href="https://drafts.csswg.org/css-align-3/#alignment-container" id="ref-for-alignment-container②">alignment container</a>). The two values specify the snapping alignment in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-4/#block-axis" id="ref-for-block-axis①">block axis</a> and <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-4/#inline-axis" id="ref-for-inline-axis">inline axis</a>, respectively, as determined by the <span id="ref-for-scroll-snap-container⑥">snap container</span>’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-4/#writing-mode" id="ref-for-writing-mode">writing mode</a>. If only one value is specified, the second value defaults to the same value.</p> <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①⑧">snap position</a> in the specified axis. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export id="valdef-scroll-snap-align-start">start</dfn> <dd> Start alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①①">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③②">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport③">snapport</a> is a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position①⑨">snap position</a> in the specified axis. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export id="valdef-scroll-snap-align-end">end</dfn> <dd> End alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①②">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③③">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport④">snapport</a> is a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②⓪">snap position</a> in the specified axis. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-align" data-dfn-type="value" data-export id="valdef-scroll-snap-align-center">center</dfn> <dd> Center alignment of this box’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①③">scroll snap area</a> within the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③④">scroll container</a>’s <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport⑤">snapport</a> is a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②①">snap position</a> in the specified axis. </dl> <p>Start and end alignments are resolved with respect to the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-4/#writing-mode" id="ref-for-writing-mode①">writing mode</a> of the <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container⑦">snap container</a> unless the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①④">scroll snap area</a> is larger than the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport⑥">snapport</a>, in which case they are resolved with respect to the <span id="ref-for-writing-mode②">writing mode</span> of the box itself. (This allows items in a container to have consistent snap alignment in general, while ensuring that <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-align-start" id="ref-for-valdef-scroll-snap-align-start">start</a> always aligns the item to allow reading its contents from the beginning.)</p> <h4 class="heading settled" data-level="5.2.1" id="snap-scope"><span class="secno">5.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 <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport⑤">scrollport</a> for optimal viewing, a scroll position cannot be considered a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②②">snap position</a> if <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①⑥">snapping</a> to it would leave the contributing <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①⑤">snap area</a> entirely outside the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport⑦">snapport</a>, even if it otherwise satisfies the required alignment of the <span id="ref-for-scroll-snap-area①⑥">snap area</span>.</p> <div class="example" id="example-40897215"> <a class="self-link" href="#example-40897215"></a> For example, a <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①⑦">snap area</a> is top-aligned to the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport⑧">snapport</a> if its top edge is coincident with the <span id="ref-for-scroll-snapport⑨">snapport</span>’s top edge; and this would be considered a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②③">snap position</a> for block-axis start-aligned snapping of that <span id="ref-for-scroll-snap-area①⑧">snap area</span> <em>if at least part of the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area①⑨">snap area</a> is on-screen</em>. If the entire <span id="ref-for-scroll-snap-area②⓪">snap area</span> is outside the <span id="ref-for-scroll-snapport①⓪">snapport</span>, however, then the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③⑤">scroll container</a> cannot be considered to be <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①⑦">snapped</a> because the required alignment, though satisfied, would not be relevant to the viewer. <figure> <pre class="ascii-art">╔════viewport════╗┈┈┈┈┈┈┈┈┌──────────────┐ ║ ┌─────┐ ┌──┐ ║ │ top-snapping │ ║ ├──┐ │ └──┘ ║ │ element │ ║ └──┴──┘ ║ │ │ ╚════════════════╝ │ │ └──────────────┘ </pre> <figcaption> Alignment of an off-screen element is not considered <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①⑧">snapping</a>. </figcaption> </figure> </div> <details class="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 later.) </details> <p class="note" role="note"><span class="marker">Note:</span> Although <a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type⑧">scroll-snap-type: both</a> evaluates <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②④">snap positions</a> independently in each axis, <a href="#choosing">choosing</a> of a <span id="ref-for-scroll-snap-position②⑤">snap position</span> in one axis can be influenced by <span id="ref-for-scroll-snap-position②⑥">snap positions</span> in the other axis. For example, snapping in one axis may push off-screen the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②①">snap area</a> that the other axis would otherwise align to, making its <span id="ref-for-scroll-snap-position②⑦">snap position</span> invalid and therefore unchooseable.</p> <h4 class="heading settled" data-level="5.2.2" id="snap-overflow"><span class="secno">5.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②②">snap area</a> is larger than the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①①">snapport</a> in a particular axis, then any scroll position in which</p> <ul> <li data-md> <p>the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②③">snap area</a> covers the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①②">snapport</a>, and</p> <li data-md> <p>the distance between the geometrically previous and subsequent otherwise-valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②⑧">snap positions</a> in that axis is larger than size of the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①③">snapport</a> in that axis,</p> </ul> <p>is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position②⑨">snap position</a> in that axis.</p> <p>The UA may use the specified alignment as a more precise target for certain scroll operations (e.g. explicit paging).</p> <div class="example" id="example-8f4980a0"> <a class="self-link" href="#example-8f4980a0"></a> For example, take the first example in <a href="#examples">§ 2 Motivating Examples</a>, 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②④">snap area</a> is larger than the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-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 it is scrolled sufficiently to trigger snapping to a different <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position③⓪">snap position</a>.</p> </div> <div class="example" id="example-e9209b74"> <a class="self-link" href="#example-e9209b74"></a> For another example, mandatory top-snapping on nested <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/sections.html#the-section-element" id="ref-for-the-section-element">section</a></code> elements can produce large snapping areas (from large top-level sections) potentially filled with smaller snapping areas (from the subsections). When the subsections are small enough, they snap normally; when they’re longer, the viewer can scroll arbitrarily within them, or within a large segment of the top-level section that has no subsections to snap to. <figure> <pre class="ascii-art">┌─ top-level section ─┐ ━┓ ┳ 1 (scroll position = 0) │ │ 1┃ ┃ │ │ ┃ ┃ │ │ ━┩ ┃ │ │ ┆ ╿ │ │ ┆ │ │ │ ┆ │ │┌─── sub-section ───┐│ ╯ ━┓ ┿ 2 │└───────────────────┘│ 2┃ │ │┌─── sub-section ───┐│ ━┓ ┃ ┿ 3 ││ ││ 3┃ ━┛ │ │└───────────────────┘│ ┃ │ │┌─── sub-section ───┐│ ━┛ ━┓ ┿ 4 │└───────────────────┘│ 4┃ │ │┌─── sub-section ───┐│ ━┓ ┃ ╈ 5 ││ ││ 5┃ ━┛ ┃ ││ ││ ┃ ┃ ││ ││ ━┩ ┃ ││ ││ ┆ ┃ ││ ││ ┆ ╹ ││ ││ ┆ │└───────────────────┘│ ┆ └─────────────────────┘ ╯ </pre> <figcaption> In the figure above, the five numbered viewports represent the five snap positions associated with the top-level section and its four subsections. Because the first and last snap positions are part of ranges taller than the viewport, the viewer is allowed to scroll freely between the top and bottom of each range. <p>Any position in that range is a valid <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position③①">snap position</a>, which can be snapped to when it is the nearest position; however, if the element is targetted directly (such as by a fragment ID or a scrolling API), the UA will land on the bolded position, which corresponds to the ideal requested alignment of the element’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②⑤">snap area</a> within the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①⑤">snapport</a>.</p> </figcaption> </figure> <p class="note" role="note"><span class="marker">Note:</span> If the author had instead set mandatory snap positions on the <em>headings</em> of each section (rather than the sections themselves), the contents of the first and fifth sections would be partially inaccessible to the user, as the heading snap area does not extend to cover the whole section. This is why it’s a bad idea to use mandatory snap positions on elements that might be widely spaced apart.</p> </div> <h4 class="heading settled" data-level="5.2.3" id="unreachable"><span class="secno">5.2.3. </span><span class="content"> Unreachable Snap Positions</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③②">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" id="ref-for-scroll-container③⑥">scroll container</a>’s viewport past the edge of its <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region①">scrollable overflow area</a>, the <em>used</em> <span id="ref-for-scroll-snap-position③③">snap position</span> for this <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-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 <span id="ref-for-scroll-snap-position③④">snap position</span>.</p> <h3 class="heading settled" data-level="5.3" id="scroll-snap-stop"><span class="secno">5.3. </span><span class="content">Scroll Snap Limits: the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop①">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><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">normal <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①⓪">|</a> always <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>normal <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>specified keyword <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>discrete </table> <p>When scrolling with an intended direction, the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③⑦">scroll container</a> can “pass over” several possible <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position③⑤">snap positions</a> (that would be valid to snap to, if the scrolling operation used the same direction but a lesser distance) before reaching the natural endpoint of the scroll operation and selecting its final <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-position" id="ref-for-scroll-position①">scroll position</a>. The <a class="property css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop②">scroll-snap-stop</a> property allows such a possible <span id="ref-for-scroll-snap-position③⑥">snap position</span> to “trap” the scrolling operation, forcing the <span id="ref-for-scroll-container③⑧">scroll container</span> to stop before the scrolling operation would naturally end.</p> <p>Values are defined as follows:</p> <dl> <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-stop" data-dfn-type="value" data-export id="valdef-scroll-snap-stop-normal">normal</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container③⑨">scroll container</a> may pass over a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position③⑦">snap position</a> defined by this element during the execution of a scrolling operation. <dt><dfn class="dfn-paneled css" data-dfn-for="scroll-snap-stop" data-dfn-type="value" data-export id="valdef-scroll-snap-stop-always">always</dfn> <dd> The <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⓪">scroll container</a> must not pass over a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position③⑧">snap position</a> defined by this element during the execution of a scrolling operation; it must instead snap to the first of this element’s <span id="ref-for-scroll-snap-position③⑨">snap positions</span>. </dl> <p>This property has no effect on scrolling operations with only an <a data-link-type="dfn" href="#intended-end-position" id="ref-for-intended-end-position">intended end position</a>, as they do not conceptually “pass over” any <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position④⓪">snap positions</a>.</p> <h2 class="heading settled" data-level="6" id="snap-concepts"><span class="secno">6. </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④①">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="6.1" id="scroll-types"><span class="secno">6.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><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="intended-end-position">intended end position</dfn> <dd data-md> <div class="example" id="example-3822aa28"> <a class="self-link" href="#example-3822aa28"></a> Common examples of scrolls with only an <a data-link-type="dfn" href="#intended-end-position" id="ref-for-intended-end-position①">intended end position</a> include: <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" id="ref-for-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> <li data-md> <p>homing operations such as the <kbd>Home</kbd>/<kbd>End</kbd> keys</p> </ul> </div> <dt data-md><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="intended-direction-and-end-position">intended direction and end position</dfn> <dd data-md> <div class="example" id="example-f50b3650"> <a class="self-link" href="#example-f50b3650"></a> Common examples of scrolls with both an <a data-link-type="dfn" href="#intended-direction-and-end-position" id="ref-for-intended-direction-and-end-position">intended direction and end position</a> include: <ul> <li data-md> <p>a “fling” gesture, interpreted with momentum</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" id="ref-for-dom-window-scrollby">scrollBy()</a></code></p> <li data-md> <p>paging operations such as the <kbd>PgUp</kbd>/<kbd>PgDn</kbd> keys (or equivalent operations on the scrollbar)</p> </ul> </div> <p>The intended end point of the scroll prior to intervention from features such as snap points is its <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="natural-end-point">natural end-point</dfn>.</p> <dt data-md><dfn class="dfn-paneled" data-dfn-type="dfn" data-export id="intended-direction">intended direction</dfn> <dd data-md> <div class="example" id="example-33cf1041"> <a class="self-link" href="#example-33cf1041"></a> Common examples of scrolls with only an <a data-link-type="dfn" href="#intended-direction" id="ref-for-intended-direction">intended direction</a> include: <ul> <li data-md> <p>pressing an arrow key on the keyboard (or equivalent operations on the scrollbar)</p> <li data-md> <p>a swiping gesture interpreted as a fixed (rather than inertial) scroll</p> </ul> </div> </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">axis-locked</a> scroll is bound to only scroll along that axis. This prevents less-precise input mechanisms from drifting in the non-primary axis.</p> <p class="note" role="note"><span class="marker">Note:</span> This specification only applies to scrolling methods supported by the user agent; it does not require the user agent to support any particular input or scrolling method.</p> <h3 class="heading settled" data-level="6.2" id="choosing"><span class="secno">6.2. </span><span class="content">Choosing Snap Positions</span><a class="self-link" href="#choosing"></a></h3> <p>A <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④①">scroll container</a> can have many <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②⑦">snap areas</a> scattered throughout its <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region②">scrollable overflow area</a>. A naïve algorithm for selecting a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-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 data-md> <p><a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position④③">Snap positions</a> should be chosen to minimize the distance between the end-point (or the <a data-link-type="dfn" href="#natural-end-point" id="ref-for-natural-end-point">natural end-point</a>) and the final snapped scroll position, subject to the additional constraints listed in this section.</p> <li data-md> <p>If a scroll is <a data-link-type="dfn" href="#axis-lock" id="ref-for-axis-lock①">axis-locked</a>, any <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position④④">snap positions</a> in the other axis should be ignored during the scroll. (However, <span id="ref-for-scroll-snap-position④⑤">snap positions</span> in the other axis can still effect the final scroll position.)</p> <li data-md> <p>In order to prevent a far-offscreen element from having difficult-to-understand effects on the scroll position, <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position④⑥">snap positions</a> should be ignored if their elements are far outside of the “corridor” that the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①⑥">snapport</a> defines as it moves through the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region③">scrollable overflow area</a>, or a hypothetical “corridor” in the direction of a scroll with only an <a data-link-type="dfn" href="#intended-direction" id="ref-for-intended-direction①">intended direction</a>, or the <span id="ref-for-scroll-snapport①⑦">snapport</span> after an scroll with only an <a data-link-type="dfn" href="#intended-end-position" id="ref-for-intended-end-position②">intended end position</a>.</p> <li data-md> <p>User agents <em>must</em> ensure that a user can “escape” a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position④⑦">snap position</a>, regardless of the scroll method. For example, if the snap type is <a class="css" data-link-type="maybe" href="#valdef-scroll-snap-type-mandatory" id="ref-for-valdef-scroll-snap-type-mandatory②">mandatory</a> and the next <span id="ref-for-scroll-snap-position④⑧">snap position</span> is more than two screen-widths away, a naïve “always snap to nearest” selection algorithm might “trap” the user if their end position was only one screen-width away. Instead, a smarter algorithm that only returned to the starting <span id="ref-for-scroll-snap-position④⑨">snap position</span> if the end-point was a fairly small distance from it, and otherwise ignored the starting snap position, would give better behavior.</p> <p>(This implies that a scroll with only an <a data-link-type="dfn" href="#intended-direction" id="ref-for-intended-direction②">intended direction</a> must always ignore the starting <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤⓪">snap positions</a>.)</p> <li data-md> <p>If a page is navigated to a fragment that defines a target element (e.g. one that would be matched by <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo①">:target</a>, or the target of <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview①">scrollIntoView()</a></code>), and that element defines some <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤①">snap positions</a>, the user agent must <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap①⑨">snap</a> to one of that element’s <span id="ref-for-scroll-snap-position⑤②">snap positions</span> if its nearest <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④②">scroll container</a> is a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container⑧">scroll snap container</a>. The user agent <em>may</em> also do this even when the <span id="ref-for-scroll-container④③">scroll container</span> has <a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type⑨">scroll-snap-type: none</a>.</p> </ul> <h4 class="heading settled" data-level="6.2.1" id="multiple-aligned-snap-areas"><span class="secno">6.2.1. </span><span class="content">Selecting between multiple aligned snap areas</span><a class="self-link" href="#multiple-aligned-snap-areas"></a></h4> <p>When <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②⓪">snapping</a> to a scroll position that is aligned with multiple <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②⑧">scroll snap areas</a>, the following algorithm procedure is used to determined which box is <span id="ref-for-scroll-snap②①">snapped</span> on the block and inline axes for a particular <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④④">scroll container</a>:</p> <ol> <li data-md> <p>Let <var>scroll position</var> be the scroll position of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⑤">scroll container</a></p> <li data-md> <p>Let <var>inline</var> be the set of boxes whose <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area②⑨">scroll snap areas</a> are aligned at this <var>scroll position</var> in the inline axis.</p> <li data-md> <p>Let <var>block</var> be the set of boxes whose <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③⓪">scroll snap areas</a> are aligned at this <var>scroll position</var> in the block axis.</p> <li data-md> <p>For each <var>list</var> of <var>block</var> and <var>inline</var>:</p> <ol> <li data-md> <p>If <var>list</var> contains the focused box, remove all other boxes from <var>list</var>.</p> <li data-md> <p>If <var>list</var> contains the targeted box, remove all other boxes from <var>list</var>.</p> <li data-md> <p>For each <var>box</var> in <var>list</var>:</p> <ol> <li data-md> <p>Remove any box from <var>list</var> which is an ancestor of <var>box</var>.</p> </ol> </ol> <li data-md> <p>If <var>inline</var> and <var>block</var> are overlapping sets:</p> <ol> <li data-md> <p>Replace <var>inline</var> with the intersection of <var>inline</var> and <var>block</var>.</p> <li data-md> <p>Replace <var>block</var> with the intersection of <var>inline</var> and <var>block</var>.</p> </ol> <li data-md> <p>Select the first element in <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-order" id="ref-for-concept-tree-order">tree order</a> from <var>inline</var> as the <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②②">snapped</a> inline axis box.</p> <li data-md> <p>Select the first element in <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-tree-order" id="ref-for-concept-tree-order①">tree order</a> from <var>block</var> as the <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②③">snapped</a> block axis box.</p> </ol> <h2 class="heading settled" id="longhands"><span class="content">Appendix A: Longhands</span><a class="self-link" href="#longhands"></a></h2> <p>The physical and logical longhands (and their shorthands) interact as defined in <a data-link-type="biblio" href="#biblio-css-logical-1" title="CSS Logical Properties and Values Level 1">[CSS-LOGICAL-1]</a>.</p> <h3 class="heading settled" id="padding-longhands-physical"><span class="content">Physical Longhands for <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding⑦">scroll-padding</a></span><a class="self-link" href="#padding-longhands-physical"></a></h3> <table class="def propdef" data-link-for-hint="scroll-padding-top"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-top">scroll-padding-top</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-right">scroll-padding-right</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-bottom">scroll-padding-bottom</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-left">scroll-padding-left</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①①">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage③"><length-percentage [0,∞]></a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>auto <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⑥">scroll containers</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>relative to the scroll container’s scrollport <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>the keyword <a class="css" data-link-type="maybe" href="#valdef-scroll-padding-auto" id="ref-for-valdef-scroll-padding-auto①">auto</a> or a computed <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage④"><length-percentage></a> value <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://drafts.csswg.org/css-logical-1/#logical-property-group">Logical property group:</a> <td><a class="css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding⑧">scroll-padding</a> </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding⑨">scroll-padding</a> specify the top, right, bottom, and left edges of the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①⑧">snapport</a>, respectively. Negative values are invalid.</p> <h3 class="heading settled" id="padding-longhands-logical"><span class="content">Flow-relative Longhands for <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①⓪">scroll-padding</a></span><a class="self-link" href="#padding-longhands-logical"></a></h3> <table class="def propdef" data-link-for-hint="scroll-padding-inline-start"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-inline-start">scroll-padding-inline-start</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-block-start">scroll-padding-block-start</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-inline-end">scroll-padding-inline-end</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-block-end">scroll-padding-block-end</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①②">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage⑤"><length-percentage [0,∞]></a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>auto <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⑦">scroll containers</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>relative to the scroll container’s scrollport <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>the keyword <a class="css" data-link-type="maybe" href="#valdef-scroll-padding-auto" id="ref-for-valdef-scroll-padding-auto②">auto</a> or a computed <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage⑥"><length-percentage></a> value <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://drafts.csswg.org/css-logical-1/#logical-property-group">Logical property group:</a> <td><a class="css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①①">scroll-padding</a> </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand①">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①②">scroll-padding</a> specify the block-start, inline-start, block-end, and inline-end edges of the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport①⑨">snapport</a>, respectively. Negative values are invalid.</p> <table class="def propdef" data-link-for-hint="scroll-padding-block"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-block">scroll-padding-block</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-padding-inline">scroll-padding-inline</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod">[ auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#comb-one" id="ref-for-comb-one①③">|</a> <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#typedef-length-percentage" id="ref-for-typedef-length-percentage⑦"><length-percentage [0,∞]></a> ]<a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-num-range" id="ref-for-mult-num-range③">{1,2}</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>auto <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⑧">scroll containers</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>relative to the scroll container’s scrollport <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>see individual properties <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#shorthand-property" id="ref-for-shorthand-property②">shorthands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-padding-block-start" id="ref-for-propdef-scroll-padding-block-start">scroll-padding-block-start</a> + <a class="property css" data-link-type="property" href="#propdef-scroll-padding-block-end" id="ref-for-propdef-scroll-padding-block-end">scroll-padding-block-end</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-padding-inline-start" id="ref-for-propdef-scroll-padding-inline-start">scroll-padding-inline-start</a> + <a class="property css" data-link-type="property" href="#propdef-scroll-padding-inline-end" id="ref-for-propdef-scroll-padding-inline-end">scroll-padding-inline-end</a> are <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand②">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①③">scroll-padding</a>, and specify the block-axis and inline-axis edges of the <a data-link-type="dfn" href="#scroll-snapport" id="ref-for-scroll-snapport②⓪">snapport</a>, respectively.</p> <p>If two values are specified, the first gives the start value and the second gives the end value.</p> <p>If only one value is specified, the second value defaults to the same value.</p> <h3 class="heading settled" id="margin-longhands-physical"><span class="content">Physical Longhands for <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin③">scroll-margin</a></span><a class="self-link" href="#margin-longhands-physical"></a></h3> <table class="def propdef" data-link-for-hint="scroll-margin-top"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-top">scroll-margin-top</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-right">scroll-margin-right</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-bottom">scroll-margin-bottom</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-left">scroll-margin-left</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#length-value" id="ref-for-length-value①"><length></a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>0 <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>absolute length <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://drafts.csswg.org/css-logical-1/#logical-property-group">Logical property group:</a> <td><a class="css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin④">scroll-margin</a> </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand③">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin⑤">scroll-margin</a> specify the top, right, bottom, and left edges of the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③①">scroll snap area</a>, respectively.</p> <h3 class="heading settled" id="margin-longhands-logical"><span class="content">Flow-relative Longhands for <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin⑥">scroll-margin</a></span><a class="self-link" href="#margin-longhands-logical"></a></h3> <table class="def propdef" data-link-for-hint="scroll-margin-block-start"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-block-start">scroll-margin-block-start</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-inline-start">scroll-margin-inline-start</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-block-end">scroll-margin-block-end</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-inline-end">scroll-margin-inline-end</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#length-value" id="ref-for-length-value②"><length></a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>0 <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>absolute length <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://drafts.csswg.org/css-logical-1/#logical-property-group">Logical property group:</a> <td><a class="css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin⑦">scroll-margin</a> </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand④">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin⑧">scroll-margin</a> specify the block-start, inline-start, block-end, and inline-end edges of the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③②">scroll snap area</a>, respectively.</p> <table class="def propdef" data-link-for-hint="scroll-margin-block"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-block">scroll-margin-block</dfn>, <dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-scroll-margin-inline">scroll-margin-inline</dfn> <tr class="value"> <th><a href="https://www.w3.org/TR/css-values/#value-defs">Value:</a> <td class="prod"><a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#length-value" id="ref-for-length-value③"><length></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-num-range" id="ref-for-mult-num-range④">{1,2}</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#initial-values">Initial:</a> <td>0 <tr> <th><a href="https://www.w3.org/TR/css-cascade/#applies-to">Applies to:</a> <td><a href="https://www.w3.org/TR/css-pseudo/#generated-content" title="Includes ::before and ::after pseudo-elements.">all elements</a> <tr> <th><a href="https://www.w3.org/TR/css-cascade/#inherited-property">Inherited:</a> <td>no <tr> <th><a href="https://www.w3.org/TR/css-values/#percentages">Percentages:</a> <td>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>see individual properties <tr> <th><a href="https://www.w3.org/TR/web-animations/#animation-type">Animation type:</a> <td>by computed value type <tr> <th><a href="https://www.w3.org/TR/cssom/#serializing-css-values">Canonical order:</a> <td>per grammar </table> <p>These <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#shorthand-property" id="ref-for-shorthand-property③">shorthands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-margin-block-start" id="ref-for-propdef-scroll-margin-block-start">scroll-margin-block-start</a> + <a class="property css" data-link-type="property" href="#propdef-scroll-margin-block-end" id="ref-for-propdef-scroll-margin-block-end">scroll-margin-block-end</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-margin-inline-start" id="ref-for-propdef-scroll-margin-inline-start">scroll-margin-inline-start</a> + <a class="property css" data-link-type="property" href="#propdef-scroll-margin-inline-end" id="ref-for-propdef-scroll-margin-inline-end">scroll-margin-inline-end</a> are <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-5/#longhand" id="ref-for-longhand⑤">longhands</a> of <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin⑨">scroll-margin</a>, and specify the block-axis and inline-axis edges of the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③③">scroll snap area</a>, respectively.</p> <p>If two values are specified, the first gives the start value and the second gives the end value.</p> <p>If only one value is specified, the second value defaults to the same value.</p> <h2 class="heading settled" data-level="7" id="priv-sec"><span class="secno">7. </span><span class="content">Privacy and Security Considerations</span><a class="self-link" href="#priv-sec"></a></h2> <p>This specification does not expose any information whatsoever that is not already exposed to the DOM directly; it just makes scrolling slightly more functional. There are no new privacy or security considerations.</p> <h2 class="heading settled" data-level="8" id="acknowledgements"><span class="secno">8. </span><span class="content">Acknowledgements</span><a class="self-link" href="#acknowledgements"></a></h2> <p>Many thanks to David Baron, Simon Fraser, Håkon Wium Lie, Theresa O’Connor, François Remy, Majid Valpour, and most especially Robert O’Callahan for their proposals and recommendations, which have been incorporated into this document.</p> <h2 class="heading settled" data-level="9" id="changes"><span class="secno">9. </span><span class="content">Changes</span><a class="self-link" href="#changes"></a></h2> <h3 class="heading settled" data-level="9.1" id="changes-20190319"><span class="secno">9.1. </span><span class="content">Changes Since 19 March 2019 CR</span><a class="self-link" href="#changes-20190319"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/">19 March 2019 Candidate Recommendation</a> include:</p> <ul> <li id="change-2019-clarify-writing-mode"><a class="self-link" href="#change-2019-clarify-writing-mode"></a> Specified which writing mode is used to resolve <a class="property css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align③">scroll-snap-align</a>. (<a href="https://github.com/w3c/csswg-drafts/issues/3815">Issue 3815</a>) <li id="change-2019-resnap-multiple"> <a class="self-link" href="#change-2019-resnap-multiple"></a> Define requirements for re-snapping when multiple elements coincide. (<a href="https://github.com/w3c/csswg-drafts/issues/4651">Issue 4651</a>) <blockquote> <p> If the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④⑨">scroll container</a> was <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②④">snapped</a> before the content change and that same <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤③">snap position</a> still exists (e.g. its associated element was not deleted), the scroll container must be re-snapped to that same snap position after the content change. <ins>If multiple boxes were <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②⑤">snapped</a> before and their <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤④">snap positions</a> no longer coincide, then if one of them is focused or targeted, the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤⓪">scroll container</a> must re-snap to that one and otherwise which one to re-snap to is UA-defined. (The UA may, for example, track which element is snapped as layout shifts align and de-align the <span id="ref-for-scroll-snap-position⑤⑤">snap positions</span> of other elements.) </ins> </p> </blockquote> <li id="change-2019-resnap-animation"> <a class="self-link" href="#change-2019-resnap-animation"></a> Require re-snapping to a new element to animate the same way as any other scroll-into-view operation. (<a href="https://github.com/w3c/csswg-drafts/issues/4609">Issue 4609</a>) <blockquote> <p> <ins>Scrolling required by a re-snap operation to a new or different box must behave and animate the same way as any other scroll-into-view operation, including honoring controls such as <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-scroll-behavior" id="ref-for-propdef-scroll-behavior①">scroll-behavior</a>. Scrolling behavior for re-snapping to the same box as before however, is UA-defined. The UA may, for example, when snapped to the start of a section, choose not to animation the scroll to the section’s new position as content is dynamically added earlier in the document in order to create the illusion of not scrolling. </ins> </p> </blockquote> <li id="change-2019-propagation"> <a class="self-link" href="#change-2019-propagation"></a> Defined explicitly that <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①⓪">scroll-snap-type</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①④">scroll-padding</a> values are propagated from the root element to the document viewport as would be expected. (<a href="https://github.com/w3c/csswg-drafts/issues/3740">Issue 3740</a>) <blockquote> <p> <ins>UAs must apply the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①①">scroll-snap-type</a> value set on the root element to the document viewport. Note that, unlike <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow" id="ref-for-propdef-overflow②">overflow</a>, <span class="property" id="ref-for-propdef-scroll-snap-type①②">scroll-snap-type</span> values are <em>not</em> propagated from HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/sections.html#the-body-element" id="ref-for-the-body-element②">body</a></code>.</ins> </p> </blockquote> <blockquote> <p> <ins>UAs must apply the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①⑤">scroll-padding</a> values set on the root element to the document viewport. (Note that, unlike <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow" id="ref-for-propdef-overflow③">overflow</a>, <span class="property" id="ref-for-propdef-scroll-padding①⑥">scroll-padding</span> values are <em>not</em> propagated from HTML <code><a data-link-type="element" href="https://html.spec.whatwg.org/multipage/sections.html#the-body-element" id="ref-for-the-body-element③">body</a></code>.)</ins> </p> </blockquote> <li id="change-2019-padding-viewport"> <a class="self-link" href="#change-2019-padding-viewport"></a> Clarified that while snap alignment is relative to the visual viewport, <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①⑦">scroll-padding</a> is resolved against the layout viewport, so that <span class="property" id="ref-for-propdef-scroll-padding①⑧">scroll-padding</span> and <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-position-3/#propdef-inset" id="ref-for-propdef-inset">inset</a> are consistent on the root viewport. (<a href="https://github.com/w3c/csswg-drafts/issues/4393">Issue 4393</a>) <blockquote> <p> Defines an inward offset from the corresponding edge of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport⑥">scrollport</a>. <ins>When applied to the root viewport, the offset is calculated and applied relative to the layout viewport (rather than the visual viewport) the same way as the corresponding <a data-link-type="dfn" href="https://drafts.csswg.org/css-logical-1/#inset-properties" id="ref-for-inset-properties①">inset properties</a> on <a data-link-type="dfn" href="https://drafts.csswg.org/css-position-3/#fixed-position" id="ref-for-fixed-position①">fixed-positioned boxes</a>; the <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region③">optimal viewing region</a> is the remaining area that intersects with the visual viewport.</ins> </p> </blockquote> <li id="change-2019-padding-applies-to"><a class="self-link" href="#change-2019-padding-applies-to"></a> Corrected the “Applies to” line for <a class="property css" data-link-type="property" href="#propdef-scroll-padding-inline" id="ref-for-propdef-scroll-padding-inline">scroll-padding-inline</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-padding-block" id="ref-for-propdef-scroll-padding-block">scroll-padding-block</a>. (<a href="https://github.com/w3c/csswg-drafts/issues/5845">Issue 5845</a>) </ul> <p>A <a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2019">Disposition of Comments</a> is available.</p> <h3 class="heading settled" data-level="9.2" id="changes-20190131"><span class="secno">9.2. </span><span class="content">Changes Since 31 January 2019 CR</span><a class="self-link" href="#changes-20190131"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190131/">31 January 2019 Candidate Recommendation</a> include:</p> <ul> <li id="change-2019-clarify-nonsnapping"> <a class="self-link" href="#change-2019-clarify-nonsnapping"></a> Emphasized that <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding①⑨">scroll-padding</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①⓪">scroll-margin</a> do apply even when scroll snapping is off. (<a href="https://github.com/w3c/csswg-drafts/issues/3721">Issue 3721</a>) <blockquote> <p> <ins>Also, to offer better control over paging and scroll positioning even when snapping is off, this module defines the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②⓪">scroll-padding</a> property for use on all <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤①">scroll containers</a>, to adjust the <span id="ref-for-scroll-container⑤②">scroll container</span>’s <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region④">optimal viewing region</a> for the purpose of paging and scroll-into-view operations; similarly the <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①①">scroll-margin</a> property can be used on any box to adjust its visual area for the purpose of scroll-into-view operations.</ins> </p> </blockquote> <blockquote> <p> This property specifies <ins>(for all <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤③">scroll containers</a>, not just <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container⑨">scroll snap containers</a>)</ins> offsets that define the <a data-link-type="dfn" href="#optimal-viewing-region" id="ref-for-optimal-viewing-region⑤">optimal viewing region</a> of a scrollport… </p> </blockquote> <blockquote> <p> If a page is navigated to a fragment that defines a target element (one that would be matched by <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo②">:target</a>, or the target of <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview②">scrollIntoView()</a></code>), the UA should use the element’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③④">scroll snap area</a>, rather than just its border box, to determine which area of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region④">scrollable overflow area</a> to bring into view <ins>, <em>even when snapping is off or not applied on this element</em></ins> . </p> </blockquote> </ul> <h3 class="heading settled" data-level="9.3" id="changes-20180814"><span class="secno">9.3. </span><span class="content">Changes Since 14 August 2018 CR</span><a class="self-link" href="#changes-20180814"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2018/CR-css-scroll-snap-1-20180814/">14 August 2018 Candidate Recommendation</a> include:</p> <ul> <li id="change-2018-padding-initial"><a class="self-link" href="#change-2018-padding-initial"></a> Corrected <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②①">scroll-padding</a> longhands to list the new <a class="css" data-link-type="maybe" href="#valdef-scroll-padding-auto" id="ref-for-valdef-scroll-padding-auto③">auto</a> keyword in their property definition tables. (<a href="https://github.com/w3c/csswg-drafts/issues/3189">Issue 3189</a>) <li id="change-2018-computed-animation"><a class="self-link" href="#change-2018-computed-animation"></a> Fixed up “Computed value” and “Animation type” lines in the property definition tables. <li id="change-2018-margin-percentage"><a class="self-link" href="#change-2018-margin-percentage"></a> Cleaned up stray <a class="production css" data-link-type="type" href="https://drafts.csswg.org/css-values-4/#percentage-value" id="ref-for-percentage-value"><percentage></a> values in <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①②">scroll-margin</a> property definition tables. (<a href="https://github.com/w3c/csswg-drafts/issues/3289">3289</a>) </ul> <p>A <a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2018">Disposition of Comments is available</a>.</p> <h3 class="heading settled" data-level="9.4" id="changes-20171214"><span class="secno">9.4. </span><span class="content">Changes Since 14 December 2017 CR</span><a class="self-link" href="#changes-20171214"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20171214/">14 December 2017 Candidate Recommendation</a> include:</p> <ul> <li id="change-2017-align-values-backwards"><a class="self-link" href="#change-2017-align-values-backwards"></a> Fixed <a class="property css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align④">scroll-snap-align</a> shorthand to assign block-axis value first, inline-axis value second, accordingly to logical shorthand conventions. (<a href="https://github.com/w3c/csswg-drafts/issues/2232">Issue 2232</a> <li id="change-2017-scroll-padding-auto"><a class="self-link" href="#change-2017-scroll-padding-auto"></a> Added <a class="css" data-link-type="maybe" href="#valdef-scroll-padding-auto" id="ref-for-valdef-scroll-padding-auto④">auto</a> keyword to 'scroll-padding as its initial value to account for UA heuristics. (<a href="https://github.com/w3c/csswg-drafts/issues/2728">Issue 2728</a> <li id="change-2017-snap-vs-api-scroll"> <a class="self-link" href="#change-2017-snap-vs-api-scroll"></a> Clarified in the definition of <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①③">scroll-snap-type</a> that programmatic scrolls such as <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto" id="ref-for-dom-window-scrollto②">scrollTo()</a></code> are also subject to snapping. (<a href="https://github.com/w3c/csswg-drafts/issues/2593">Issue 2593</a>) <blockquote> Using the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①④">scroll-snap-type</a> property on the relevant <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤④">scroll container</a>, the author can request a particular bias for the scrollport to land on a <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤⑥">snap position</a> after scrolling operations <ins>(including programmatic scrolls such as the <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto" id="ref-for-dom-window-scrollto③">scrollTo()</a></code> method)</ins> . </blockquote> <li id="change-2017-clarify-mandatory-visibility"><a class="self-link" href="#change-2017-clarify-mandatory-visibility"></a> Adjusted wording in <a href="#snap-scope">§ 5.2.1 Scoping Valid Snap Positions to Visible Boxes</a> to be clearer—compared to <a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20171214/#snap-scope">old version</a>. (<a href="https://github.com/w3c/csswg-drafts/issues/2526">Issue 2526</a>) </ul> <p>A <a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2017-12">Disposition of Comments</a> is available.</p> <h3 class="heading settled" data-level="9.5" id="changes-20170824"><span class="secno">9.5. </span><span class="content">Changes Since 24 August 2017 CR</span><a class="self-link" href="#changes-20170824"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2017/CR-css-scroll-snap-1-20170824/">24 August 2017 Candidate Recommendation</a> include:</p> <ul> <li id="change-2017-scroll-margin"> <a class="self-link" href="#change-2017-scroll-margin"></a> <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo③">:target</a>/<code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview③">scrollIntoView()</a></code>/etc should take <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①③">scroll-margin</a> into account, regardless of whether snapping is turned on or not. (<a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2016-08#issue-1">Issue 1</a> <blockquote> <p> <ins>If a page is navigated to a fragment that defines a target element (one that would be matched by <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo④">:target</a>, or the target of <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview④">scrollIntoView()</a></code>), the UA should use the element’s <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③⑤">scroll snap area</a>, rather than just its border box, to determine which area of the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region" id="ref-for-scrollable-overflow-region⑤">scrollable overflow area</a> to bring into view.</ins> </p> </blockquote> <li id="change-2017-target-snap-must"> <a class="self-link" href="#change-2017-target-snap-must"></a> <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo⑤">:target</a>/<code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview⑤">scrollIntoView()</a></code>/etc must (rather than should) use snap positions if snapping is turned on. (<a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2016-08#issue-1">Issue 1</a> <blockquote> <p> If a page is navigated to a fragment that defines a target element (one that would be matched by <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/selectors-4/#target-pseudo" id="ref-for-target-pseudo⑥">:target</a>, or the target of <code class="idl"><a data-link-type="idl" href="https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview" id="ref-for-dom-element-scrollintoview⑥">scrollIntoView()</a></code>), and that element defines some <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤⑦">snap positions</a>, the user agent <del>should</del> <ins>must</ins> <a data-link-type="dfn" href="#scroll-snap" id="ref-for-scroll-snap②⑥">snap</a> to one of that element’s <span id="ref-for-scroll-snap-position⑤⑧">snap positions</span> <ins>if its nearest <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤⑤">scroll container</a> is a <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container①⓪">scroll snap container</a></ins> . The user agent <em>may</em> also do this even when the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤⑥">scroll container</a> has <a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①⑤">scroll-snap-type: none</a>. </p> </blockquote> <li id="change-2017-rename-scroll-margin"><a class="self-link" href="#change-2017-rename-scroll-margin"></a> Renamed <span class="css">scroll-snap-margin</span> to <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①④">scroll-margin</a> to reflect its more generic role in providing breathing space for scrolling to an element regardless of snapping behavior. (<a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2016-08#issue-4">Issue 4</a>) </ul> <p>A <a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2016-08">Disposition of Comments</a> is available.</p> <h3 class="heading settled" data-level="9.6" id="changes-20161020"><span class="secno">9.6. </span><span class="content">Changes Since 20 October 2016 CR</span><a class="self-link" href="#changes-20161020"></a></h3> <p>Changes since the <a href="https://www.w3.org/TR/2016/CR-css-scroll-snap-1-20161020/">20 October 2016 Candidate Recommendation</a> include:</p> <ul> <li> Restricted <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②②">scroll-padding</a> to non-negative values. (<a href="https://github.com/w3c/csswg-drafts/issues/1084">Issue 1084</a>) <blockquote> <p> Values <ins>must be non-negative and</ins> are interpreted as for <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-box-4/#propdef-padding" id="ref-for-propdef-padding①">padding</a> … </p> </blockquote> <li>Added paging and homing operations to examples in <a href="#scroll-types">§ 6.1 Types of Scrolling Methods</a>. (<a href="https://github.com/w3c/csswg-drafts/issues/1605">Issue 1605</a>) <li> Clarified that snapping in one axis may affect whether snapping to a particular snap area is possible in the other axis. (<a href="https://github.com/w3c/csswg-drafts/issues/950">Issue 950</a>) <blockquote> <ins> <p class="note" role="note">Although <a class="css" data-link-type="propdesc" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①⑥">scroll-snap-type: both</a> evaluates <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑤⑨">snap positions</a> independently in each axis, <a href="#choosing">choosing</a> of a <span id="ref-for-scroll-snap-position⑥⓪">snap position</span> in one axis may be influenced by <span id="ref-for-scroll-snap-position⑥①">snap positions</span> in the other axis. For example, snapping in one axis may push off-screen the <a data-link-type="dfn" href="#scroll-snap-area" id="ref-for-scroll-snap-area③⑥">snap area</a> that the other axis would otherwise align to, making its <span id="ref-for-scroll-snap-position⑥②">snap position</span> invalid and therefore unchooseable.</p> </ins> </blockquote> <li>Clarified how the <a class="property css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②③">scroll-padding</a> and <a class="property css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①⑤">scroll-margin</a> shorthands assign values to their longhands. (<a href="https://github.com/w3c/csswg-drafts/issues/1050">Issue 1050</a>) <li> Clarified that scroll snapping does not mandate any particular input method. (<a href="https://github.com/w3c/csswg-drafts/issues/1305">Issue 1305</a>) <blockquote> <ins> <p class="note" role="note">This specification only applies to scrolling methods supported by the user agent; it does not require the user agent to support any particular input or scrolling method.</p> </ins> </blockquote> <li>Clarified the intended effects of <a class="property css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop③">scroll-snap-stop</a> on various scrolling operations. (<a href="https://github.com/w3c/csswg-drafts/issues/1552">Issue 1552</a>) <li>Clarified that <a class="property css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop④">scroll-snap-stop</a> is applied to the <a data-link-type="dfn" href="#scroll-snap-position" id="ref-for-scroll-snap-position⑥③">snap positions</a> defined by the element, not applied to all <span id="ref-for-scroll-snap-position⑥④">snap positions</span> in the <a data-link-type="dfn" href="#scroll-snap-container" id="ref-for-scroll-snap-container①①">scroll snap container</a>. <li>Fixed some syntax errors in examples and added a new one to the <a class="property css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①⑦">scroll-snap-type</a> section. (<a href="https://github.com/w3c/csswg-drafts/issues/827">Issue 827</a>) </ul> <p>A <a href="https://drafts.csswg.org/css-scroll-snap-1/issues-cr-2016">Disposition of Comments</a> is available.</p> </main> <h2 class="no-ref no-num heading settled" id="w3c-conformance"><span class="content"> Conformance</span><a class="self-link" href="#w3c-conformance"></a></h2> <h3 class="no-ref heading settled" id="w3c-conventions"><span class="content"> Document conventions</span><a class="self-link" href="#w3c-conventions"></a></h3> <p>Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification. </p> <p>All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. <a data-link-type="biblio" href="#biblio-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">[RFC2119]</a></p> <p>Examples in this specification are introduced with the words “for example” or are set apart from the normative text with <code>class="example"</code>, like this: </p> <div class="example" id="w3c-example"> <a class="self-link" href="#w3c-example"></a> <p>This is an example of an informative example.</p> </div> <p>Informative notes begin with the word “Note” and are set apart from the normative text with <code>class="note"</code>, like this: </p> <p class="note" role="note">Note, this is an informative note.</p> <p>Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <code><strong class="advisement"></code>, like this: <strong class="advisement"> UAs MUST provide an accessible alternative. </strong></p> <details class="wpt-tests-block" dir="ltr" lang="en" open> <summary>Tests</summary> <p>Tests relating to the content of this specification may be documented in “Tests” blocks like this one. Any such block is non-normative.</p> <ul class="wpt-tests-list"></ul> <hr> </details> <h3 class="no-ref heading settled" id="w3c-conformance-classes"><span class="content"> Conformance classes</span><a class="self-link" href="#w3c-conformance-classes"></a></h3> <p>Conformance to this specification is defined for three conformance classes: </p> <dl> <dt>style sheet <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS style sheet</a>. <dt>renderer <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a> that interprets the semantics of a style sheet and renders documents that use them. <dt>authoring tool <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a> that writes a style sheet. </dl> <p>A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module. </p> <p>A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.) </p> <p>An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module. </p> <h3 class="no-ref heading settled" id="w3c-partial"><span class="content"> Partial implementations</span><a class="self-link" href="#w3c-partial"></a></h3> <p>So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers <strong>must</strong> treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore as appropriate</a>) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents <strong>must not</strong> selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.</p> <h4 class="heading settled" id="w3c-conform-future-proofing"><span class="content"> Implementations of Unstable and Proprietary Features</span><a class="self-link" href="#w3c-conform-future-proofing"></a></h4> <p>To avoid clashes with future stable CSS features, the CSSWG recommends <a href="http://www.w3.org/TR/CSS/#future-proofing">following best practices</a> for the implementation of <a href="http://www.w3.org/TR/CSS/#unstable">unstable</a> features and <a href="http://www.w3.org/TR/CSS/#proprietary-extension">proprietary extensions</a> to CSS. </p> <h3 class="no-ref heading settled" id="w3c-testing"><span class="content"> Non-experimental implementations</span><a class="self-link" href="#w3c-testing"></a></h3> <p>Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec. </p> <p>To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group. </p> <p>Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>. Questions should be directed to the <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a> mailing list.</p> <script src="https://www.w3.org/scripts/TR/2021/fixup.js"></script> <h2 class="no-num no-ref heading settled" id="index"><span class="content">Index</span><a class="self-link" href="#index"></a></h2> <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="content">Terms defined by this specification</span><a class="self-link" href="#index-defined-here"></a></h3> <ul class="index"> <li><a href="#valdef-scroll-snap-stop-always">always</a><span>, in § 5.3</span> <li><a href="#valdef-scroll-padding-auto">auto</a><span>, in § 4.2</span> <li><a href="#axis-lock">axis-lock</a><span>, in § 6.1</span> <li><a href="#axis-value">axis value</a><span>, in § 4.1.1</span> <li><a href="#valdef-scroll-snap-type-block">block</a><span>, in § 4.1.1</span> <li><a href="#valdef-scroll-snap-type-both">both</a><span>, in § 4.1.1</span> <li><a href="#captures-snap-positions">captures snap positions</a><span>, in § 4.1.2</span> <li><a href="#valdef-scroll-snap-align-center">center</a><span>, in § 5.2</span> <li><a href="#valdef-scroll-snap-align-end">end</a><span>, in § 5.2</span> <li><a href="#valdef-scroll-snap-type-inline">inline</a><span>, in § 4.1.1</span> <li><a href="#intended-direction">intended direction</a><span>, in § 6.1</span> <li><a href="#intended-direction-and-end-position">intended direction and end position</a><span>, in § 6.1</span> <li><a href="#intended-end-position">intended end position</a><span>, in § 6.1</span> <li><a href="#valdef-scroll-padding-length-percentage-0"><length-percentage [0,∞]></a><span>, in § 4.2</span> <li><a href="#valdef-scroll-snap-type-mandatory">mandatory</a><span>, in § 4.1.2</span> <li><a href="#natural-end-point">natural end-point</a><span>, in § 6.1</span> <li> none <ul> <li><a href="#valdef-scroll-snap-align-none">value for scroll-snap-align</a><span>, in § 5.2</span> <li><a href="#valdef-scroll-snap-type-none">value for scroll-snap-type</a><span>, in § 4.1.2</span> </ul> <li><a href="#valdef-scroll-snap-stop-normal">normal</a><span>, in § 5.3</span> <li><a href="#optimal-viewing-region">optimal viewing region</a><span>, in § 4.2</span> <li><a href="#valdef-scroll-snap-type-proximity">proximity</a><span>, in § 4.1.2</span> <li><a href="#re-snap">re-snap</a><span>, in § 4.1.2</span> <li><a href="#propdef-scroll-margin">scroll-margin</a><span>, in § 5.1</span> <li><a href="#propdef-scroll-margin-block">scroll-margin-block</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-block-end">scroll-margin-block-end</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-block-start">scroll-margin-block-start</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-bottom">scroll-margin-bottom</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-inline">scroll-margin-inline</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-inline-end">scroll-margin-inline-end</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-inline-start">scroll-margin-inline-start</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-left">scroll-margin-left</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-right">scroll-margin-right</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-margin-top">scroll-margin-top</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding">scroll-padding</a><span>, in § 4.2</span> <li><a href="#propdef-scroll-padding-block">scroll-padding-block</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-block-end">scroll-padding-block-end</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-block-start">scroll-padding-block-start</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-bottom">scroll-padding-bottom</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-inline">scroll-padding-inline</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-inline-end">scroll-padding-inline-end</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-inline-start">scroll-padding-inline-start</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-left">scroll-padding-left</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-right">scroll-padding-right</a><span>, in § Unnumbered section</span> <li><a href="#propdef-scroll-padding-top">scroll-padding-top</a><span>, in § Unnumbered section</span> <li><a href="#scroll-snap">scroll snap</a><span>, in § 3</span> <li><a href="#propdef-scroll-snap-align">scroll-snap-align</a><span>, in § 5.2</span> <li><a href="#scroll-snap-area">scroll snap area</a><span>, in § 5.1</span> <li><a href="#scroll-snap-container">scroll snap container</a><span>, in § 4.1.2</span> <li><a href="#scroll-snapport">scroll snapport</a><span>, in § 4.2</span> <li><a href="#scroll-snap-position">scroll snap position</a><span>, in § 3</span> <li><a href="#propdef-scroll-snap-stop">scroll-snap-stop</a><span>, in § 5.3</span> <li><a href="#propdef-scroll-snap-type">scroll-snap-type</a><span>, in § 4.1</span> <li><a href="#scroll-snap">snap</a><span>, in § 3</span> <li><a href="#scroll-snap-area">snap area</a><span>, in § 5.1</span> <li><a href="#scroll-snap-container">snap container</a><span>, in § 4.1.2</span> <li><a href="#scroll-snapport">snapport</a><span>, in § 4.2</span> <li><a href="#scroll-snap-position">snap position</a><span>, in § 3</span> <li><a href="#valdef-scroll-snap-align-start">start</a><span>, in § 5.2</span> <li><a href="#strictness-value">strictness value</a><span>, in § 4.1.2</span> <li><a href="#valdef-scroll-snap-type-x">x</a><span>, in § 4.1.1</span> <li><a href="#valdef-scroll-snap-type-y">y</a><span>, in § 4.1.1</span> </ul> <h3 class="no-num no-ref heading settled" id="index-defined-elsewhere"><span class="content">Terms defined by reference</span><a class="self-link" href="#index-defined-elsewhere"></a></h3> <ul class="index"> <li> <a data-link-type="biblio">[CSS-ALIGN-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="e7a4e2e2">alignment container</span> <li><span class="dfn-paneled" id="d15331bf">alignment subject</span> </ul> <li> <a data-link-type="biblio">[CSS-BOX-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="cecbe9cd">margin</span> <li><span class="dfn-paneled" id="b5418f3e">padding</span> </ul> <li> <a data-link-type="biblio">[CSS-CASCADE-5]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="9e066e76">longhand</span> <li><span class="dfn-paneled" id="56177fad">shorthand</span> <li><span class="dfn-paneled" id="8ca0c013">shorthand property</span> </ul> <li> <a data-link-type="biblio">[CSS-DISPLAY-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="58157ca0">containing block chain</span> </ul> <li> <a data-link-type="biblio">[CSS-LOGICAL-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="f616a86d">inset properties</span> </ul> <li> <a data-link-type="biblio">[CSS-OVERFLOW-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="86928bde">overflow</span> <li><span class="dfn-paneled" id="86923d07">scroll container</span> <li><span class="dfn-paneled" id="f2eb15d9">scroll position</span> <li><span class="dfn-paneled" id="1b08e188">scroll-behavior</span> <li><span class="dfn-paneled" id="99a64665">scrollable overflow area</span> <li><span class="dfn-paneled" id="60bbf126">scrollport</span> </ul> <li> <a data-link-type="biblio">[CSS-POSITION-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="725b73bd">fixed-positioned box</span> <li><span class="dfn-paneled" id="36789bc1">inset</span> </ul> <li> <a data-link-type="biblio">[CSS-PSEUDO-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="fd0c9e35">::after</span> <li><span class="dfn-paneled" id="a1addf6c">::first-letter</span> <li><span class="dfn-paneled" id="75bfa627">::first-line</span> </ul> <li> <a data-link-type="biblio">[CSS-VALUES-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="18222566"><length-percentage></span> <li><span class="dfn-paneled" id="fb030e6c"><length></span> <li><span class="dfn-paneled" id="15f5b381"><percentage></span> <li><span class="dfn-paneled" id="537cf076">?</span> <li><span class="dfn-paneled" id="358fd6ff">CSS-wide keywords</span> <li><span class="dfn-paneled" id="938ba280">{A,B}</span> <li><span class="dfn-paneled" id="6ec67710">|</span> </ul> <li> <a data-link-type="biblio">[CSS-WRITING-MODES-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="e1ab41b7">block axis</span> <li><span class="dfn-paneled" id="43667deb">inline axis</span> <li><span class="dfn-paneled" id="a73617e0">writing mode</span> </ul> <li> <a data-link-type="biblio">[CSSOM-VIEW-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="356b41f5">scrollBy()</span> <li><span class="dfn-paneled" id="82b885c9">scrollIntoView()</span> <li><span class="dfn-paneled" id="af017f8e">scrollTo()</span> </ul> <li> <a data-link-type="biblio">[DOM]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="25538777">tree order</span> </ul> <li> <a data-link-type="biblio">[HTML]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="2f0492ac">body</span> <li><span class="dfn-paneled" id="918ee071">section</span> </ul> <li> <a data-link-type="biblio">[SELECTORS-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="efe16f32">:target</span> </ul> </ul> <h2 class="no-num no-ref heading settled" id="references"><span class="content">References</span><a class="self-link" href="#references"></a></h2> <h3 class="no-num no-ref heading settled" id="normative"><span class="content">Normative References</span><a class="self-link" href="#normative"></a></h3> <dl> <dt id="biblio-css-align-3">[CSS-ALIGN-3] <dd>Elika Etemad; Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-align/"><cite>CSS Box Alignment Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-align/">https://drafts.csswg.org/css-align/</a> <dt id="biblio-css-box-4">[CSS-BOX-4] <dd>Elika Etemad. <a href="https://drafts.csswg.org/css-box-4/"><cite>CSS Box Model Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-box-4/">https://drafts.csswg.org/css-box-4/</a> <dt id="biblio-css-cascade-5">[CSS-CASCADE-5] <dd>Elika Etemad; Miriam Suzanne; Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-cascade-5/"><cite>CSS Cascading and Inheritance Level 5</cite></a>. URL: <a href="https://drafts.csswg.org/css-cascade-5/">https://drafts.csswg.org/css-cascade-5/</a> <dt id="biblio-css-display-4">[CSS-DISPLAY-4] <dd><a href="https://drafts.csswg.org/css-display-4/"><cite>CSS Display Module Level 4</cite></a>. Editor's Draft. URL: <a href="https://drafts.csswg.org/css-display-4/">https://drafts.csswg.org/css-display-4/</a> <dt id="biblio-css-logical-1">[CSS-LOGICAL-1] <dd>Rossen Atanassov; Elika Etemad. <a href="https://drafts.csswg.org/css-logical-1/"><cite>CSS Logical Properties and Values Level 1</cite></a>. URL: <a href="https://drafts.csswg.org/css-logical-1/">https://drafts.csswg.org/css-logical-1/</a> <dt id="biblio-css-overflow-3">[CSS-OVERFLOW-3] <dd>Elika Etemad; Florian Rivoal. <a href="https://drafts.csswg.org/css-overflow-3/"><cite>CSS Overflow Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-overflow-3/">https://drafts.csswg.org/css-overflow-3/</a> <dt id="biblio-css-position-3">[CSS-POSITION-3] <dd>Elika Etemad; Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-position-3/"><cite>CSS Positioned Layout Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-position-3/">https://drafts.csswg.org/css-position-3/</a> <dt id="biblio-css-pseudo-4">[CSS-PSEUDO-4] <dd>Daniel Glazman; Elika Etemad; Alan Stearns. <a href="https://drafts.csswg.org/css-pseudo-4/"><cite>CSS Pseudo-Elements Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-pseudo-4/">https://drafts.csswg.org/css-pseudo-4/</a> <dt id="biblio-css-values-3">[CSS-VALUES-3] <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://drafts.csswg.org/css-values-3/"><cite>CSS Values and Units Module Level 3</cite></a>. URL: <a href="https://drafts.csswg.org/css-values-3/">https://drafts.csswg.org/css-values-3/</a> <dt id="biblio-css-values-4">[CSS-VALUES-4] <dd>Tab Atkins Jr.; Elika Etemad. <a href="https://drafts.csswg.org/css-values-4/"><cite>CSS Values and Units Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-values-4/">https://drafts.csswg.org/css-values-4/</a> <dt id="biblio-css-writing-modes-4">[CSS-WRITING-MODES-4] <dd>Elika Etemad; Koji Ishii. <a href="https://drafts.csswg.org/css-writing-modes-4/"><cite>CSS Writing Modes Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-writing-modes-4/">https://drafts.csswg.org/css-writing-modes-4/</a> <dt id="biblio-css2">[CSS2] <dd>Bert Bos; et al. <a href="https://drafts.csswg.org/css2/"><cite>Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification</cite></a>. URL: <a href="https://drafts.csswg.org/css2/">https://drafts.csswg.org/css2/</a> <dt id="biblio-cssom-view-1">[CSSOM-VIEW-1] <dd>Simon Pieters. <a href="https://drafts.csswg.org/cssom-view/"><cite>CSSOM View Module</cite></a>. URL: <a href="https://drafts.csswg.org/cssom-view/">https://drafts.csswg.org/cssom-view/</a> <dt id="biblio-dom">[DOM] <dd>Anne van Kesteren. <a href="https://dom.spec.whatwg.org/"><cite>DOM Standard</cite></a>. Living Standard. URL: <a href="https://dom.spec.whatwg.org/">https://dom.spec.whatwg.org/</a> <dt id="biblio-html">[HTML] <dd>Anne van Kesteren; et al. <a href="https://html.spec.whatwg.org/multipage/"><cite>HTML Standard</cite></a>. Living Standard. URL: <a href="https://html.spec.whatwg.org/multipage/">https://html.spec.whatwg.org/multipage/</a> <dt id="biblio-rfc2119">[RFC2119] <dd>S. Bradner. <a href="https://datatracker.ietf.org/doc/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. March 1997. Best Current Practice. URL: <a href="https://datatracker.ietf.org/doc/html/rfc2119">https://datatracker.ietf.org/doc/html/rfc2119</a> <dt id="biblio-selectors-4">[SELECTORS-4] <dd>Elika Etemad; Tab Atkins Jr.. <a href="https://drafts.csswg.org/selectors/"><cite>Selectors Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/selectors/">https://drafts.csswg.org/selectors/</a> </dl> <h2 class="no-num no-ref heading settled" id="property-index"><span class="content">Property Index</span><a class="self-link" href="#property-index"></a></h2> <div class="big-element-wrapper"> <table class="index"> <thead> <tr> <th scope="col">Name <th scope="col">Value <th scope="col">Initial <th scope="col">Applies to <th scope="col">Inh. <th scope="col">%ages <th scope="col">Animation type <th scope="col">Canonical order <th scope="col">Computed value <th scope="col">Logical property group <tbody> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin" id="ref-for-propdef-scroll-margin①⑥">scroll-margin</a> <td><length>{1,4} <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>per side, an absolute length <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-block" id="ref-for-propdef-scroll-margin-block">scroll-margin-block</a> <td><length>{1,2} <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>see individual properties <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-block-end" id="ref-for-propdef-scroll-margin-block-end①">scroll-margin-block-end</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-block-start" id="ref-for-propdef-scroll-margin-block-start①">scroll-margin-block-start</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-bottom" id="ref-for-propdef-scroll-margin-bottom">scroll-margin-bottom</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-inline" id="ref-for-propdef-scroll-margin-inline">scroll-margin-inline</a> <td><length>{1,2} <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>see individual properties <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-inline-end" id="ref-for-propdef-scroll-margin-inline-end①">scroll-margin-inline-end</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-inline-start" id="ref-for-propdef-scroll-margin-inline-start①">scroll-margin-inline-start</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-left" id="ref-for-propdef-scroll-margin-left">scroll-margin-left</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-right" id="ref-for-propdef-scroll-margin-right">scroll-margin-right</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-margin-top" id="ref-for-propdef-scroll-margin-top">scroll-margin-top</a> <td><length> <td>0 <td>all elements <td>no <td>n/a <td>by computed value type <td>per grammar <td>absolute length <td>scroll-margin <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding" id="ref-for-propdef-scroll-padding②④">scroll-padding</a> <td>[ auto | <length-percentage [0,∞]> ]{1,4} <td>auto <td>scroll containers <td>no <td>relative to the corresponding dimension of the scroll container’s scrollport <td>by computed value type <td>per grammar <td>per side, either the keyword auto or a computed <length-percentage> value <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-block" id="ref-for-propdef-scroll-padding-block①">scroll-padding-block</a> <td>[ auto | <length-percentage [0,∞]> ]{1,2} <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value <td>per grammar <td>see individual properties <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-block-end" id="ref-for-propdef-scroll-padding-block-end①">scroll-padding-block-end</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-block-start" id="ref-for-propdef-scroll-padding-block-start①">scroll-padding-block-start</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-bottom" id="ref-for-propdef-scroll-padding-bottom">scroll-padding-bottom</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-inline" id="ref-for-propdef-scroll-padding-inline①">scroll-padding-inline</a> <td>[ auto | <length-percentage [0,∞]> ]{1,2} <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value <td>per grammar <td>see individual properties <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-inline-end" id="ref-for-propdef-scroll-padding-inline-end①">scroll-padding-inline-end</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-inline-start" id="ref-for-propdef-scroll-padding-inline-start①">scroll-padding-inline-start</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-left" id="ref-for-propdef-scroll-padding-left">scroll-padding-left</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-right" id="ref-for-propdef-scroll-padding-right">scroll-padding-right</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-padding-top" id="ref-for-propdef-scroll-padding-top">scroll-padding-top</a> <td>auto | <length-percentage [0,∞]> <td>auto <td>scroll containers <td>no <td>relative to the scroll container’s scrollport <td>by computed value type <td>per grammar <td>the keyword auto or a computed <length-percentage> value <td>scroll-padding <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-snap-align" id="ref-for-propdef-scroll-snap-align⑤">scroll-snap-align</a> <td>[ none | start | end | center ]{1,2} <td>none <td>all elements <td>no <td>n/a <td>discrete <td>per grammar <td>two keywords <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-snap-stop" id="ref-for-propdef-scroll-snap-stop⑤">scroll-snap-stop</a> <td>normal | always <td>normal <td>all elements <td>no <td>n/a <td>discrete <td>per grammar <td>specified keyword <td> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-scroll-snap-type" id="ref-for-propdef-scroll-snap-type①⑧">scroll-snap-type</a> <td>none | [ x | y | block | inline | both ] [ mandatory | proximity ]? <td>none <td>all elements <td>no <td>n/a <td>discrete <td>per grammar <td>specified keyword(s) <td> </table> </div> <details class="mdn-anno unpositioned" data-anno-for="margin-longhands-logical"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-block-end" title="The scroll-margin-block-end property defines the margin of the scroll snap area at the end of the block dimension that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-block-end</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-block-start" title="The scroll-margin-block-start property defines the margin of the scroll snap area at the start of the block dimension that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-block-start</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-inline-end" title="The scroll-margin-inline-end property defines the margin of the scroll snap area at the end of the inline dimension that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-inline-end</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-inline-start" title="The scroll-margin-inline-start property defines the margin of the scroll snap area at the start of the inline dimension that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-inline-start</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="propdef-scroll-margin-block"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-block" title="The scroll-margin-block shorthand property sets the scroll margins of an element in the block dimension.">scroll-margin-block</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="margin-longhands-physical"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-bottom" title="The scroll-margin-bottom property defines the bottom margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-bottom</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios yes"><span>iOS Safari</span><span>14.5+</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-left" title="The scroll-margin-left property defines the left margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-left</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios yes"><span>iOS Safari</span><span>14.5+</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-right" title="The scroll-margin-right property defines the right margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-right</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios yes"><span>iOS Safari</span><span>14.5+</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-top" title="The scroll-margin-top property defines the top margin of the scroll snap area that is used for snapping this box to the snapport. The scroll snap area is determined by taking the transformed border box, finding its rectangular bounding box (axis-aligned in the scroll container's coordinate space), then adding the specified outsets.">scroll-margin-top</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios yes"><span>iOS Safari</span><span>14.5+</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="propdef-scroll-margin-inline"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-inline" title="The scroll-margin-inline shorthand property sets the scroll margins of an element in the inline dimension.">scroll-margin-inline</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="scroll-margin"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin" title="The scroll-margin shorthand property sets all of the scroll margins of an element at once, assigning values much like the margin property does for margins of an element.">scroll-margin</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>90+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios yes"><span>iOS Safari</span><span>14.5+</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="padding-longhands-logical"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-block-end" title="The scroll-padding-block-end property defines offsets for the end edge in the block dimension of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-block-end</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-block-start" title="The scroll-padding-block-start property defines offsets for the start edge in the block dimension of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-block-start</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-inline-end" title="The scroll-padding-inline-end property defines offsets for the end edge in the inline dimension of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-inline-end</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-inline-start" title="The scroll-padding-inline-start property defines offsets for the start edge in the inline dimension of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-inline-start</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="propdef-scroll-padding-block"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-block" title="The scroll-padding-block shorthand property sets the scroll padding of an element in the block dimension.">scroll-padding-block</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="padding-longhands-physical"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-bottom" title="The scroll-padding-bottom property defines offsets for the bottom of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-bottom</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-left" title="The scroll-padding-left property defines offsets for the left of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-left</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-right" title="The scroll-padding-right property defines offsets for the right of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-right</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-top" title="The scroll-padding-top property defines offsets for the top of the optimal viewing region of the scrollport: the region used as the target region for placing things in view of the user. This allows the author to exclude regions of the scrollport that are obscured by other content (such as fixed-positioned toolbars or sidebars) or to put more breathing room between a targeted element and the edges of the scrollport.">scroll-padding-top</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="propdef-scroll-padding-inline"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-inline" title="The scroll-padding-inline shorthand property sets the scroll padding of an element in the inline dimension.">scroll-padding-inline</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="scroll-padding"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding" title="The scroll-padding shorthand property sets scroll padding on all sides of an element at once, much like the padding property does for padding on an element.">scroll-padding</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>14.1+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="scroll-snap-align"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-align" title="The scroll-snap-align property specifies the box's snap position as an alignment of its snap area (as the alignment subject) within its snap container's snapport (as the alignment container). The two values specify the snapping alignment in the block axis and inline axis, respectively. If only one value is specified, the second value defaults to the same value.">scroll-snap-align</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>68+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="scroll-snap-stop"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-stop" title="The scroll-snap-stop CSS property defines whether or not the scroll container is allowed to "pass over" possible snap positions.">scroll-snap-stop</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>103+</span></span><span class="safari yes"><span>Safari</span><span>15+</span></span><span class="chrome yes"><span>Chrome</span><span>75+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>?</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android no"><span>Firefox for Android</span><span>?</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <details class="mdn-anno unpositioned" data-anno-for="scroll-snap-type"> <summary><b class="all-engines-flag" title="This feature is in all current engines.">✔</b><span>MDN</span></summary> <div class="feature"> <p><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type" title="The scroll-snap-type CSS property sets how strictly snap points are enforced on the scroll container in case there is one.">scroll-snap-type</a></p> <p class="all-engines-text">In all current engines.</p> <div class="support"> <span class="firefox yes"><span>Firefox</span><span>99+</span></span><span class="safari yes"><span>Safari</span><span>11+</span></span><span class="chrome yes"><span>Chrome</span><span>69+</span></span> <hr> <span class="opera no"><span>Opera</span><span>?</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span> <hr> <span class="edge no"><span>Edge (Legacy)</span><span>None</span></span><span class="ie no"><span>IE</span><span>None</span></span> <hr> <span class="firefox_android yes"><span>Firefox for Android</span><span>68+</span></span><span class="safari_ios no"><span>iOS Safari</span><span>?</span></span><span class="chrome_android no"><span>Chrome for Android</span><span>?</span></span><span class="webview_android no"><span>Android WebView</span><span>?</span></span><span class="samsunginternet_android no"><span>Samsung Internet</span><span>?</span></span><span class="opera_android no"><span>Opera Mobile</span><span>?</span></span> </div> </div> </details> <script>/* Boilerplate: script-dom-helper */ "use strict"; function query(sel) { return document.querySelector(sel); } function queryAll(sel) { return [...document.querySelectorAll(sel)]; } function iter(obj) { if(!obj) return []; var it = obj[Symbol.iterator]; if(it) return it; return Object.entries(obj); } function mk(tagname, attrs, ...children) { const el = document.createElement(tagname); for(const [k,v] of iter(attrs)) { if(k.slice(0,3) == "_on") { const eventName = k.slice(3); el.addEventListener(eventName, v); } else if(k[0] == "_") { // property, not attribute el[k.slice(1)] = v; } else { if(v === false || v == null) { continue; } else if(v === true) { el.setAttribute(k, ""); continue; } else { el.setAttribute(k, v); } } } append(el, children); return el; } /* Create shortcuts for every known HTML element */ [ "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", "b", "base", "basefont", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", "head", "header", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "label", "legend", "li", "link", "main", "map", "mark", "meta", "meter", "nav", "nobr", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "s", "samp", "script", "section", "select", "small", "source", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "u", "ul", "var", "video", "wbr", "xmp", ].forEach(tagname=>{ mk[tagname] = (...args) => mk(tagname, ...args); }); function* nodesFromChildList(children) { for(const child of children.flat(Infinity)) { if(child instanceof Node) { yield child; } else { yield new Text(child); } } } function append(el, ...children) { for(const child of nodesFromChildList(children)) { if(el instanceof Node) el.appendChild(child); else el.push(child); } return el; } function insertAfter(el, ...children) { for(const child of nodesFromChildList(children)) { el.parentNode.insertBefore(child, el.nextSibling); } return el; } function clearContents(el) { el.innerHTML = ""; return el; } function parseHTML(markup) { if(markup.toLowerCase().trim().indexOf('<!doctype') === 0) { const doc = document.implementation.createHTMLDocument(""); doc.documentElement.innerHTML = markup; return doc; } else { const el = mk.template({}); el.innerHTML = markup; return el.content; } }</script> <script>/* Boilerplate: script-dfn-panel */ "use strict"; { let dfnPanelData = { "15f5b381": {"dfnID":"15f5b381","dfnText":"<percentage>","external":true,"refSections":[{"refs":[{"id":"ref-for-percentage-value"}],"title":"9.3. Changes Since 14 August 2018 CR"}],"url":"https://drafts.csswg.org/css-values-4/#percentage-value"}, "18222566": {"dfnID":"18222566","dfnText":"<length-percentage>","external":true,"refSections":[{"refs":[{"id":"ref-for-typedef-length-percentage"},{"id":"ref-for-typedef-length-percentage\u2460"},{"id":"ref-for-typedef-length-percentage\u2461"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-typedef-length-percentage\u2462"},{"id":"ref-for-typedef-length-percentage\u2463"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-typedef-length-percentage\u2464"},{"id":"ref-for-typedef-length-percentage\u2465"},{"id":"ref-for-typedef-length-percentage\u2466"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"https://drafts.csswg.org/css-values-4/#typedef-length-percentage"}, "1b08e188": {"dfnID":"1b08e188","dfnText":"scroll-behavior","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-behavior"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-propdef-scroll-behavior\u2460"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-overflow-3/#propdef-scroll-behavior"}, "25538777": {"dfnID":"25538777","dfnText":"tree order","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-tree-order"},{"id":"ref-for-concept-tree-order\u2460"}],"title":"6.2.1. Selecting between multiple aligned snap areas"}],"url":"https://dom.spec.whatwg.org/#concept-tree-order"}, "2f0492ac": {"dfnID":"2f0492ac","dfnText":"body","external":true,"refSections":[{"refs":[{"id":"ref-for-the-body-element"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-the-body-element\u2460"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-the-body-element\u2461"},{"id":"ref-for-the-body-element\u2462"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://html.spec.whatwg.org/multipage/sections.html#the-body-element"}, "356b41f5": {"dfnID":"356b41f5","dfnText":"scrollBy()","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-window-scrollby"}],"title":"6.1. Types of Scrolling Methods"}],"url":"https://drafts.csswg.org/cssom-view-1/#dom-window-scrollby"}, "358fd6ff": {"dfnID":"358fd6ff","dfnText":"CSS-wide keywords","external":true,"refSections":[{"refs":[{"id":"ref-for-css-wide-keywords"}],"title":"1.2. Value Definitions"}],"url":"https://drafts.csswg.org/css-values-4/#css-wide-keywords"}, "36789bc1": {"dfnID":"36789bc1","dfnText":"inset","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-inset"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-position-3/#propdef-inset"}, "43667deb": {"dfnID":"43667deb","dfnText":"inline axis","external":true,"refSections":[{"refs":[{"id":"ref-for-inline-axis"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"https://drafts.csswg.org/css-writing-modes-4/#inline-axis"}, "537cf076": {"dfnID":"537cf076","dfnText":"?","external":true,"refSections":[{"refs":[{"id":"ref-for-mult-opt"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"}],"url":"https://drafts.csswg.org/css-values-4/#mult-opt"}, "56177fad": {"dfnID":"56177fad","dfnText":"shorthand","external":true,"refSections":[{"refs":[{"id":"ref-for-shorthand-property"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-shorthand-property\u2460"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-shorthand-property\u2461"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-shorthand-property\u2462"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"https://drafts.csswg.org/css-cascade-5/#shorthand-property"}, "58157ca0": {"dfnID":"58157ca0","dfnText":"containing block chain","external":true,"refSections":[{"refs":[{"id":"ref-for-containing-block-chain"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-containing-block-chain\u2460"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"}],"url":"https://drafts.csswg.org/css-display-4/#containing-block-chain"}, "60bbf126": {"dfnID":"60bbf126","dfnText":"scrollport","external":true,"refSections":[{"refs":[{"id":"ref-for-scrollport"},{"id":"ref-for-scrollport\u2460"},{"id":"ref-for-scrollport\u2461"},{"id":"ref-for-scrollport\u2462"},{"id":"ref-for-scrollport\u2463"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-scrollport\u2464"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scrollport\u2465"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-overflow-3/#scrollport"}, "6ec67710": {"dfnID":"6ec67710","dfnText":"|","external":true,"refSections":[{"refs":[{"id":"ref-for-comb-one"},{"id":"ref-for-comb-one\u2460"},{"id":"ref-for-comb-one\u2461"},{"id":"ref-for-comb-one\u2462"},{"id":"ref-for-comb-one\u2463"},{"id":"ref-for-comb-one\u2464"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-comb-one\u2465"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-comb-one\u2466"},{"id":"ref-for-comb-one\u2467"},{"id":"ref-for-comb-one\u2468"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-comb-one\u2460\u24ea"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"},{"refs":[{"id":"ref-for-comb-one\u2460\u2460"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-comb-one\u2460\u2461"},{"id":"ref-for-comb-one\u2460\u2462"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"https://drafts.csswg.org/css-values-4/#comb-one"}, "725b73bd": {"dfnID":"725b73bd","dfnText":"fixed-positioned box","external":true,"refSections":[{"refs":[{"id":"ref-for-fixed-position"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-fixed-position\u2460"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-position-3/#fixed-position"}, "75bfa627": {"dfnID":"75bfa627","dfnText":"::first-line","external":true,"refSections":[{"refs":[{"id":"ref-for-selectordef-first-line"}],"title":"1.1. Module interactions"}],"url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line"}, "82b885c9": {"dfnID":"82b885c9","dfnText":"scrollIntoView()","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-element-scrollintoview"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-dom-element-scrollintoview\u2460"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-dom-element-scrollintoview\u2461"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-dom-element-scrollintoview\u2462"},{"id":"ref-for-dom-element-scrollintoview\u2463"},{"id":"ref-for-dom-element-scrollintoview\u2464"},{"id":"ref-for-dom-element-scrollintoview\u2465"}],"title":"9.5. Changes Since 24 August 2017 CR"}],"url":"https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview"}, "86923d07": {"dfnID":"86923d07","dfnText":"scroll container","external":true,"refSections":[{"refs":[{"id":"ref-for-scroll-container"}],"title":"Unnumbered Section"},{"refs":[{"id":"ref-for-scroll-container\u2460"},{"id":"ref-for-scroll-container\u2461"},{"id":"ref-for-scroll-container\u2462"}],"title":"1. Introduction"},{"refs":[{"id":"ref-for-scroll-container\u2463"},{"id":"ref-for-scroll-container\u2464"},{"id":"ref-for-scroll-container\u2465"},{"id":"ref-for-scroll-container\u2466"}],"title":"2. Motivating Examples"},{"refs":[{"id":"ref-for-scroll-container\u2467"},{"id":"ref-for-scroll-container\u2468"},{"id":"ref-for-scroll-container\u2460\u24ea"},{"id":"ref-for-scroll-container\u2460\u2460"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-scroll-container\u2460\u2461"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-scroll-container\u2460\u2462"},{"id":"ref-for-scroll-container\u2460\u2463"},{"id":"ref-for-scroll-container\u2460\u2464"},{"id":"ref-for-scroll-container\u2460\u2465"},{"id":"ref-for-scroll-container\u2460\u2466"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"},{"refs":[{"id":"ref-for-scroll-container\u2460\u2467"},{"id":"ref-for-scroll-container\u2460\u2468"},{"id":"ref-for-scroll-container\u2461\u24ea"},{"id":"ref-for-scroll-container\u2461\u2460"},{"id":"ref-for-scroll-container\u2461\u2461"},{"id":"ref-for-scroll-container\u2461\u2462"},{"id":"ref-for-scroll-container\u2461\u2463"},{"id":"ref-for-scroll-container\u2461\u2464"},{"id":"ref-for-scroll-container\u2461\u2465"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-scroll-container\u2461\u2466"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-container\u2461\u2467"},{"id":"ref-for-scroll-container\u2461\u2468"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-scroll-container\u2462\u24ea"},{"id":"ref-for-scroll-container\u2462\u2460"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-scroll-container\u2462\u2461"},{"id":"ref-for-scroll-container\u2462\u2462"},{"id":"ref-for-scroll-container\u2462\u2463"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-scroll-container\u2462\u2464"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scroll-container\u2462\u2465"}],"title":"5.2.3. \nUnreachable Snap Positions"},{"refs":[{"id":"ref-for-scroll-container\u2462\u2466"},{"id":"ref-for-scroll-container\u2462\u2467"},{"id":"ref-for-scroll-container\u2462\u2468"},{"id":"ref-for-scroll-container\u2463\u24ea"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"},{"refs":[{"id":"ref-for-scroll-container\u2463\u2460"},{"id":"ref-for-scroll-container\u2463\u2461"},{"id":"ref-for-scroll-container\u2463\u2462"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-container\u2463\u2463"},{"id":"ref-for-scroll-container\u2463\u2464"}],"title":"6.2.1. Selecting between multiple aligned snap areas"},{"refs":[{"id":"ref-for-scroll-container\u2463\u2465"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-scroll-container\u2463\u2466"},{"id":"ref-for-scroll-container\u2463\u2467"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-scroll-container\u2463\u2468"},{"id":"ref-for-scroll-container\u2464\u24ea"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-scroll-container\u2464\u2460"},{"id":"ref-for-scroll-container\u2464\u2461"},{"id":"ref-for-scroll-container\u2464\u2462"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-scroll-container\u2464\u2463"}],"title":"9.4. Changes Since 14 December 2017 CR"},{"refs":[{"id":"ref-for-scroll-container\u2464\u2464"},{"id":"ref-for-scroll-container\u2464\u2465"}],"title":"9.5. Changes Since 24 August 2017 CR"}],"url":"https://drafts.csswg.org/css-overflow-3/#scroll-container"}, "86928bde": {"dfnID":"86928bde","dfnText":"overflow","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-overflow"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-propdef-overflow\u2460"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-propdef-overflow\u2461"},{"id":"ref-for-propdef-overflow\u2462"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow"}, "8ca0c013": {"dfnID":"8ca0c013","dfnText":"shorthand property","external":true,"refSections":[{"refs":[{"id":"ref-for-shorthand-property"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-shorthand-property\u2460"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-shorthand-property\u2461"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-shorthand-property\u2462"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"https://drafts.csswg.org/css-cascade-5/#shorthand-property"}, "918ee071": {"dfnID":"918ee071","dfnText":"section","external":true,"refSections":[{"refs":[{"id":"ref-for-the-section-element"}],"title":"5.2.2. \nSnapping Boxes that Overflow the Scrollport"}],"url":"https://html.spec.whatwg.org/multipage/sections.html#the-section-element"}, "938ba280": {"dfnID":"938ba280","dfnText":"{A,B}","external":true,"refSections":[{"refs":[{"id":"ref-for-mult-num-range"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-mult-num-range\u2460"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-mult-num-range\u2461"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-mult-num-range\u2462"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-mult-num-range\u2463"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"https://drafts.csswg.org/css-values-4/#mult-num-range"}, "99a64665": {"dfnID":"99a64665","dfnText":"scrollable overflow area","external":true,"refSections":[{"refs":[{"id":"ref-for-scrollable-overflow-region"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-scrollable-overflow-region\u2460"}],"title":"5.2.3. \nUnreachable Snap Positions"},{"refs":[{"id":"ref-for-scrollable-overflow-region\u2461"},{"id":"ref-for-scrollable-overflow-region\u2462"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scrollable-overflow-region\u2463"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-scrollable-overflow-region\u2464"}],"title":"9.5. Changes Since 24 August 2017 CR"}],"url":"https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region"}, "9e066e76": {"dfnID":"9e066e76","dfnText":"longhand","external":true,"refSections":[{"refs":[{"id":"ref-for-longhand"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-longhand\u2460"},{"id":"ref-for-longhand\u2461"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-longhand\u2462"}],"title":"Physical Longhands for scroll-margin"},{"refs":[{"id":"ref-for-longhand\u2463"},{"id":"ref-for-longhand\u2464"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"https://drafts.csswg.org/css-cascade-5/#longhand"}, "a1addf6c": {"dfnID":"a1addf6c","dfnText":"::first-letter","external":true,"refSections":[{"refs":[{"id":"ref-for-selectordef-first-letter"}],"title":"1.1. Module interactions"}],"url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter"}, "a73617e0": {"dfnID":"a73617e0","dfnText":"writing mode","external":true,"refSections":[{"refs":[{"id":"ref-for-writing-mode"},{"id":"ref-for-writing-mode\u2460"},{"id":"ref-for-writing-mode\u2461"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"https://drafts.csswg.org/css-writing-modes-4/#writing-mode"}, "af017f8e": {"dfnID":"af017f8e","dfnText":"scrollTo()","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-window-scrollto"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-dom-window-scrollto\u2460"}],"title":"6.1. Types of Scrolling Methods"},{"refs":[{"id":"ref-for-dom-window-scrollto\u2461"},{"id":"ref-for-dom-window-scrollto\u2462"}],"title":"9.4. Changes Since 14 December 2017 CR"}],"url":"https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto"}, "axis-lock": {"dfnID":"axis-lock","dfnText":"axis-lock","external":false,"refSections":[{"refs":[{"id":"ref-for-axis-lock"}],"title":"6.1. Types of Scrolling Methods"},{"refs":[{"id":"ref-for-axis-lock\u2460"}],"title":"6.2. Choosing Snap Positions"}],"url":"#axis-lock"}, "axis-value": {"dfnID":"axis-value","dfnText":"axis values","external":false,"refSections":[],"url":"#axis-value"}, "b5418f3e": {"dfnID":"b5418f3e","dfnText":"padding","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-padding"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-propdef-padding\u2460"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"https://drafts.csswg.org/css-box-4/#propdef-padding"}, "captures-snap-positions": {"dfnID":"captures-snap-positions","dfnText":"captures snap positions","external":false,"refSections":[{"refs":[{"id":"ref-for-captures-snap-positions\u2460"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"}],"url":"#captures-snap-positions"}, "cecbe9cd": {"dfnID":"cecbe9cd","dfnText":"margin","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-margin"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"}],"url":"https://drafts.csswg.org/css-box-4/#propdef-margin"}, "d15331bf": {"dfnID":"d15331bf","dfnText":"alignment subject","external":true,"refSections":[{"refs":[{"id":"ref-for-alignment-subject"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-alignment-subject\u2460"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"https://drafts.csswg.org/css-align-3/#alignment-subject"}, "e1ab41b7": {"dfnID":"e1ab41b7","dfnText":"block axis","external":true,"refSections":[{"refs":[{"id":"ref-for-block-axis"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-block-axis\u2460"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"https://drafts.csswg.org/css-writing-modes-4/#block-axis"}, "e7a4e2e2": {"dfnID":"e7a4e2e2","dfnText":"alignment container","external":true,"refSections":[{"refs":[{"id":"ref-for-alignment-container"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-alignment-container\u2460"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-alignment-container\u2461"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"https://drafts.csswg.org/css-align-3/#alignment-container"}, "efe16f32": {"dfnID":"efe16f32","dfnText":":target","external":true,"refSections":[{"refs":[{"id":"ref-for-target-pseudo"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-target-pseudo\u2460"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-target-pseudo\u2461"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-target-pseudo\u2462"},{"id":"ref-for-target-pseudo\u2463"},{"id":"ref-for-target-pseudo\u2464"},{"id":"ref-for-target-pseudo\u2465"}],"title":"9.5. Changes Since 24 August 2017 CR"}],"url":"https://drafts.csswg.org/selectors-4/#target-pseudo"}, "f2eb15d9": {"dfnID":"f2eb15d9","dfnText":"scroll position","external":true,"refSections":[{"refs":[{"id":"ref-for-scroll-position"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-position\u2460"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"}],"url":"https://drafts.csswg.org/css-overflow-3/#scroll-position"}, "f616a86d": {"dfnID":"f616a86d","dfnText":"inset properties","external":true,"refSections":[{"refs":[{"id":"ref-for-inset-properties"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-inset-properties\u2460"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"https://drafts.csswg.org/css-logical-1/#inset-properties"}, "fb030e6c": {"dfnID":"fb030e6c","dfnText":"<length>","external":true,"refSections":[{"refs":[{"id":"ref-for-length-value"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-length-value\u2460"}],"title":"Physical Longhands for scroll-margin"},{"refs":[{"id":"ref-for-length-value\u2461"},{"id":"ref-for-length-value\u2462"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"https://drafts.csswg.org/css-values-4/#length-value"}, "fd0c9e35": {"dfnID":"fd0c9e35","dfnText":"::after","external":true,"refSections":[{"refs":[{"id":"ref-for-selectordef-after"}],"title":"4.1.3. \nRe-snapping After Layout Changes"}],"url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-after"}, "intended-direction": {"dfnID":"intended-direction","dfnText":"intended direction","external":false,"refSections":[{"refs":[{"id":"ref-for-intended-direction"}],"title":"6.1. Types of Scrolling Methods"},{"refs":[{"id":"ref-for-intended-direction\u2460"},{"id":"ref-for-intended-direction\u2461"}],"title":"6.2. Choosing Snap Positions"}],"url":"#intended-direction"}, "intended-direction-and-end-position": {"dfnID":"intended-direction-and-end-position","dfnText":"intended direction and end position","external":false,"refSections":[{"refs":[{"id":"ref-for-intended-direction-and-end-position"}],"title":"6.1. Types of Scrolling Methods"}],"url":"#intended-direction-and-end-position"}, "intended-end-position": {"dfnID":"intended-end-position","dfnText":"intended end position","external":false,"refSections":[{"refs":[{"id":"ref-for-intended-end-position"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"},{"refs":[{"id":"ref-for-intended-end-position\u2460"}],"title":"6.1. Types of Scrolling Methods"},{"refs":[{"id":"ref-for-intended-end-position\u2461"}],"title":"6.2. Choosing Snap Positions"}],"url":"#intended-end-position"}, "natural-end-point": {"dfnID":"natural-end-point","dfnText":"natural end-point","external":false,"refSections":[{"refs":[{"id":"ref-for-natural-end-point"}],"title":"6.2. Choosing Snap Positions"}],"url":"#natural-end-point"}, "optimal-viewing-region": {"dfnID":"optimal-viewing-region","dfnText":"optimal viewing region","external":false,"refSections":[{"refs":[{"id":"ref-for-optimal-viewing-region"}],"title":"1. Introduction"},{"refs":[{"id":"ref-for-optimal-viewing-region\u2460"},{"id":"ref-for-optimal-viewing-region\u2461"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-optimal-viewing-region\u2462"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-optimal-viewing-region\u2463"},{"id":"ref-for-optimal-viewing-region\u2464"}],"title":"9.2. Changes Since 31 January 2019 CR"}],"url":"#optimal-viewing-region"}, "propdef-scroll-margin": {"dfnID":"propdef-scroll-margin","dfnText":"scroll-margin","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-margin"}],"title":"1. Introduction"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2460"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2461"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2462"},{"id":"ref-for-propdef-scroll-margin\u2463"},{"id":"ref-for-propdef-scroll-margin\u2464"}],"title":"Physical Longhands for scroll-margin"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2465"},{"id":"ref-for-propdef-scroll-margin\u2466"},{"id":"ref-for-propdef-scroll-margin\u2467"},{"id":"ref-for-propdef-scroll-margin\u2468"}],"title":"Flow-relative Longhands for scroll-margin"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2460\u24ea"},{"id":"ref-for-propdef-scroll-margin\u2460\u2460"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2460\u2461"}],"title":"9.3. Changes Since 14 August 2018 CR"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2460\u2462"},{"id":"ref-for-propdef-scroll-margin\u2460\u2463"}],"title":"9.5. Changes Since 24 August 2017 CR"},{"refs":[{"id":"ref-for-propdef-scroll-margin\u2460\u2464"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#propdef-scroll-margin"}, "propdef-scroll-margin-block": {"dfnID":"propdef-scroll-margin-block","dfnText":"scroll-margin-block","external":false,"refSections":[],"url":"#propdef-scroll-margin-block"}, "propdef-scroll-margin-block-end": {"dfnID":"propdef-scroll-margin-block-end","dfnText":"scroll-margin-block-end","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-margin-block-end"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"#propdef-scroll-margin-block-end"}, "propdef-scroll-margin-block-start": {"dfnID":"propdef-scroll-margin-block-start","dfnText":"scroll-margin-block-start","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-margin-block-start"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"#propdef-scroll-margin-block-start"}, "propdef-scroll-margin-bottom": {"dfnID":"propdef-scroll-margin-bottom","dfnText":"scroll-margin-bottom","external":false,"refSections":[],"url":"#propdef-scroll-margin-bottom"}, "propdef-scroll-margin-inline": {"dfnID":"propdef-scroll-margin-inline","dfnText":"scroll-margin-inline","external":false,"refSections":[],"url":"#propdef-scroll-margin-inline"}, "propdef-scroll-margin-inline-end": {"dfnID":"propdef-scroll-margin-inline-end","dfnText":"scroll-margin-inline-end","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-margin-inline-end"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"#propdef-scroll-margin-inline-end"}, "propdef-scroll-margin-inline-start": {"dfnID":"propdef-scroll-margin-inline-start","dfnText":"scroll-margin-inline-start","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-margin-inline-start"}],"title":"Flow-relative Longhands for scroll-margin"}],"url":"#propdef-scroll-margin-inline-start"}, "propdef-scroll-margin-left": {"dfnID":"propdef-scroll-margin-left","dfnText":"scroll-margin-left","external":false,"refSections":[],"url":"#propdef-scroll-margin-left"}, "propdef-scroll-margin-right": {"dfnID":"propdef-scroll-margin-right","dfnText":"scroll-margin-right","external":false,"refSections":[],"url":"#propdef-scroll-margin-right"}, "propdef-scroll-margin-top": {"dfnID":"propdef-scroll-margin-top","dfnText":"scroll-margin-top","external":false,"refSections":[],"url":"#propdef-scroll-margin-top"}, "propdef-scroll-padding": {"dfnID":"propdef-scroll-padding","dfnText":"scroll-padding","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding"}],"title":"1. Introduction"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2460"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2461"},{"id":"ref-for-propdef-scroll-padding\u2462"},{"id":"ref-for-propdef-scroll-padding\u2463"},{"id":"ref-for-propdef-scroll-padding\u2464"},{"id":"ref-for-propdef-scroll-padding\u2465"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2466"},{"id":"ref-for-propdef-scroll-padding\u2467"},{"id":"ref-for-propdef-scroll-padding\u2468"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2460\u24ea"},{"id":"ref-for-propdef-scroll-padding\u2460\u2460"},{"id":"ref-for-propdef-scroll-padding\u2460\u2461"},{"id":"ref-for-propdef-scroll-padding\u2460\u2462"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2460\u2463"},{"id":"ref-for-propdef-scroll-padding\u2460\u2464"},{"id":"ref-for-propdef-scroll-padding\u2460\u2465"},{"id":"ref-for-propdef-scroll-padding\u2460\u2466"},{"id":"ref-for-propdef-scroll-padding\u2460\u2467"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2460\u2468"},{"id":"ref-for-propdef-scroll-padding\u2461\u24ea"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2461\u2460"}],"title":"9.3. Changes Since 14 August 2018 CR"},{"refs":[{"id":"ref-for-propdef-scroll-padding\u2461\u2461"},{"id":"ref-for-propdef-scroll-padding\u2461\u2462"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#propdef-scroll-padding"}, "propdef-scroll-padding-block": {"dfnID":"propdef-scroll-padding-block","dfnText":"scroll-padding-block","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-block"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"#propdef-scroll-padding-block"}, "propdef-scroll-padding-block-end": {"dfnID":"propdef-scroll-padding-block-end","dfnText":"scroll-padding-block-end","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-block-end"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"#propdef-scroll-padding-block-end"}, "propdef-scroll-padding-block-start": {"dfnID":"propdef-scroll-padding-block-start","dfnText":"scroll-padding-block-start","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-block-start"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"#propdef-scroll-padding-block-start"}, "propdef-scroll-padding-bottom": {"dfnID":"propdef-scroll-padding-bottom","dfnText":"scroll-padding-bottom","external":false,"refSections":[],"url":"#propdef-scroll-padding-bottom"}, "propdef-scroll-padding-inline": {"dfnID":"propdef-scroll-padding-inline","dfnText":"scroll-padding-inline","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-inline"}],"title":"9.1. Changes Since 19 March 2019 CR"}],"url":"#propdef-scroll-padding-inline"}, "propdef-scroll-padding-inline-end": {"dfnID":"propdef-scroll-padding-inline-end","dfnText":"scroll-padding-inline-end","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-inline-end"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"#propdef-scroll-padding-inline-end"}, "propdef-scroll-padding-inline-start": {"dfnID":"propdef-scroll-padding-inline-start","dfnText":"scroll-padding-inline-start","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-padding-inline-start"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"#propdef-scroll-padding-inline-start"}, "propdef-scroll-padding-left": {"dfnID":"propdef-scroll-padding-left","dfnText":"scroll-padding-left","external":false,"refSections":[],"url":"#propdef-scroll-padding-left"}, "propdef-scroll-padding-right": {"dfnID":"propdef-scroll-padding-right","dfnText":"scroll-padding-right","external":false,"refSections":[],"url":"#propdef-scroll-padding-right"}, "propdef-scroll-padding-top": {"dfnID":"propdef-scroll-padding-top","dfnText":"scroll-padding-top","external":false,"refSections":[],"url":"#propdef-scroll-padding-top"}, "propdef-scroll-snap-align": {"dfnID":"propdef-scroll-snap-align","dfnText":"scroll-snap-align","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-snap-align"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-propdef-scroll-snap-align\u2460"},{"id":"ref-for-propdef-scroll-snap-align\u2461"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-propdef-scroll-snap-align\u2462"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-propdef-scroll-snap-align\u2463"}],"title":"9.4. Changes Since 14 December 2017 CR"}],"url":"#propdef-scroll-snap-align"}, "propdef-scroll-snap-stop": {"dfnID":"propdef-scroll-snap-stop","dfnText":"scroll-snap-stop","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-snap-stop\u2460"},{"id":"ref-for-propdef-scroll-snap-stop\u2461"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"},{"refs":[{"id":"ref-for-propdef-scroll-snap-stop\u2462"},{"id":"ref-for-propdef-scroll-snap-stop\u2463"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#propdef-scroll-snap-stop"}, "propdef-scroll-snap-type": {"dfnID":"propdef-scroll-snap-type","dfnText":"scroll-snap-type","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2460"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2461"},{"id":"ref-for-propdef-scroll-snap-type\u2462"},{"id":"ref-for-propdef-scroll-snap-type\u2463"},{"id":"ref-for-propdef-scroll-snap-type\u2464"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2465"},{"id":"ref-for-propdef-scroll-snap-type\u2466"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2467"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2468"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2460\u24ea"},{"id":"ref-for-propdef-scroll-snap-type\u2460\u2460"},{"id":"ref-for-propdef-scroll-snap-type\u2460\u2461"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2460\u2462"},{"id":"ref-for-propdef-scroll-snap-type\u2460\u2463"}],"title":"9.4. Changes Since 14 December 2017 CR"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2460\u2464"}],"title":"9.5. Changes Since 24 August 2017 CR"},{"refs":[{"id":"ref-for-propdef-scroll-snap-type\u2460\u2465"},{"id":"ref-for-propdef-scroll-snap-type\u2460\u2466"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#propdef-scroll-snap-type"}, "re-snap": {"dfnID":"re-snap","dfnText":"4.1.3. \nRe-snapping After Layout Changes","external":false,"refSections":[{"refs":[{"id":"ref-for-re-snap"}],"title":"4.1.3. \nRe-snapping After Layout Changes"}],"url":"#re-snap"}, "scroll-snap": {"dfnID":"scroll-snap","dfnText":"snapping","external":false,"refSections":[{"refs":[{"id":"ref-for-scroll-snap"},{"id":"ref-for-scroll-snap\u2460"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-scroll-snap\u2461"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-scroll-snap\u2462"},{"id":"ref-for-scroll-snap\u2463"},{"id":"ref-for-scroll-snap\u2464"},{"id":"ref-for-scroll-snap\u2465"},{"id":"ref-for-scroll-snap\u2466"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"},{"refs":[{"id":"ref-for-scroll-snap\u2467"},{"id":"ref-for-scroll-snap\u2468"},{"id":"ref-for-scroll-snap\u2460\u24ea"},{"id":"ref-for-scroll-snap\u2460\u2460"},{"id":"ref-for-scroll-snap\u2460\u2461"},{"id":"ref-for-scroll-snap\u2460\u2462"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-scroll-snap\u2460\u2463"},{"id":"ref-for-scroll-snap\u2460\u2464"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-snap\u2460\u2465"},{"id":"ref-for-scroll-snap\u2460\u2466"},{"id":"ref-for-scroll-snap\u2460\u2467"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scroll-snap\u2460\u2468"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap\u2461\u24ea"},{"id":"ref-for-scroll-snap\u2461\u2460"},{"id":"ref-for-scroll-snap\u2461\u2461"},{"id":"ref-for-scroll-snap\u2461\u2462"}],"title":"6.2.1. Selecting between multiple aligned snap areas"},{"refs":[{"id":"ref-for-scroll-snap\u2461\u2463"},{"id":"ref-for-scroll-snap\u2461\u2464"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-scroll-snap\u2461\u2465"}],"title":"9.5. Changes Since 24 August 2017 CR"}],"url":"#scroll-snap"}, "scroll-snap-area": {"dfnID":"scroll-snap-area","dfnText":"scroll snap area","external":false,"refSections":[{"refs":[{"id":"ref-for-scroll-snap-area"},{"id":"ref-for-scroll-snap-area\u2460"},{"id":"ref-for-scroll-snap-area\u2461"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462"},{"id":"ref-for-scroll-snap-area\u2463"},{"id":"ref-for-scroll-snap-area\u2464"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-snap-area\u2465"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-scroll-snap-area\u2466"},{"id":"ref-for-scroll-snap-area\u2467"},{"id":"ref-for-scroll-snap-area\u2468"}],"title":"5.1. Scroll Snapping Area: the scroll-margin property"},{"refs":[{"id":"ref-for-scroll-snap-area\u2460\u24ea"},{"id":"ref-for-scroll-snap-area\u2460\u2460"},{"id":"ref-for-scroll-snap-area\u2460\u2461"},{"id":"ref-for-scroll-snap-area\u2460\u2462"},{"id":"ref-for-scroll-snap-area\u2460\u2463"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-scroll-snap-area\u2460\u2464"},{"id":"ref-for-scroll-snap-area\u2460\u2465"},{"id":"ref-for-scroll-snap-area\u2460\u2466"},{"id":"ref-for-scroll-snap-area\u2460\u2467"},{"id":"ref-for-scroll-snap-area\u2460\u2468"},{"id":"ref-for-scroll-snap-area\u2461\u24ea"},{"id":"ref-for-scroll-snap-area\u2461\u2460"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scroll-snap-area\u2461\u2461"},{"id":"ref-for-scroll-snap-area\u2461\u2462"},{"id":"ref-for-scroll-snap-area\u2461\u2463"},{"id":"ref-for-scroll-snap-area\u2461\u2464"}],"title":"5.2.2. \nSnapping Boxes that Overflow the Scrollport"},{"refs":[{"id":"ref-for-scroll-snap-area\u2461\u2465"}],"title":"5.2.3. \nUnreachable Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap-area\u2461\u2466"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap-area\u2461\u2467"},{"id":"ref-for-scroll-snap-area\u2461\u2468"},{"id":"ref-for-scroll-snap-area\u2462\u24ea"}],"title":"6.2.1. Selecting between multiple aligned snap areas"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462\u2460"}],"title":"Physical Longhands for scroll-margin"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462\u2461"},{"id":"ref-for-scroll-snap-area\u2462\u2462"}],"title":"Flow-relative Longhands for scroll-margin"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462\u2463"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462\u2464"}],"title":"9.5. Changes Since 24 August 2017 CR"},{"refs":[{"id":"ref-for-scroll-snap-area\u2462\u2465"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#scroll-snap-area"}, "scroll-snap-container": {"dfnID":"scroll-snap-container","dfnText":"scroll snap container","external":false,"refSections":[{"refs":[{"id":"ref-for-scroll-snap-container"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-scroll-snap-container\u2460"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-scroll-snap-container\u2461"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-snap-container\u2462"},{"id":"ref-for-scroll-snap-container\u2463"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-scroll-snap-container\u2464"},{"id":"ref-for-scroll-snap-container\u2465"},{"id":"ref-for-scroll-snap-container\u2466"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-scroll-snap-container\u2467"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap-container\u2468"}],"title":"9.2. Changes Since 31 January 2019 CR"},{"refs":[{"id":"ref-for-scroll-snap-container\u2460\u24ea"}],"title":"9.5. Changes Since 24 August 2017 CR"},{"refs":[{"id":"ref-for-scroll-snap-container\u2460\u2460"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#scroll-snap-container"}, "scroll-snap-position": {"dfnID":"scroll-snap-position","dfnText":"scroll snap positions","external":false,"refSections":[{"refs":[{"id":"ref-for-scroll-snap-position"}],"title":"1. Introduction"},{"refs":[{"id":"ref-for-scroll-snap-position\u2460"},{"id":"ref-for-scroll-snap-position\u2461"},{"id":"ref-for-scroll-snap-position\u2462"},{"id":"ref-for-scroll-snap-position\u2463"},{"id":"ref-for-scroll-snap-position\u2464"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-scroll-snap-position\u2465"},{"id":"ref-for-scroll-snap-position\u2466"},{"id":"ref-for-scroll-snap-position\u2467"},{"id":"ref-for-scroll-snap-position\u2468"},{"id":"ref-for-scroll-snap-position\u2460\u24ea"},{"id":"ref-for-scroll-snap-position\u2460\u2460"},{"id":"ref-for-scroll-snap-position\u2460\u2461"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"},{"refs":[{"id":"ref-for-scroll-snap-position\u2460\u2462"},{"id":"ref-for-scroll-snap-position\u2460\u2463"},{"id":"ref-for-scroll-snap-position\u2460\u2464"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-scroll-snap-position\u2460\u2465"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-scroll-snap-position\u2460\u2466"},{"id":"ref-for-scroll-snap-position\u2460\u2467"},{"id":"ref-for-scroll-snap-position\u2460\u2468"},{"id":"ref-for-scroll-snap-position\u2461\u24ea"},{"id":"ref-for-scroll-snap-position\u2461\u2460"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-scroll-snap-position\u2461\u2461"},{"id":"ref-for-scroll-snap-position\u2461\u2462"},{"id":"ref-for-scroll-snap-position\u2461\u2463"},{"id":"ref-for-scroll-snap-position\u2461\u2464"},{"id":"ref-for-scroll-snap-position\u2461\u2465"},{"id":"ref-for-scroll-snap-position\u2461\u2466"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scroll-snap-position\u2461\u2467"},{"id":"ref-for-scroll-snap-position\u2461\u2468"},{"id":"ref-for-scroll-snap-position\u2462\u24ea"},{"id":"ref-for-scroll-snap-position\u2462\u2460"}],"title":"5.2.2. \nSnapping Boxes that Overflow the Scrollport"},{"refs":[{"id":"ref-for-scroll-snap-position\u2462\u2461"},{"id":"ref-for-scroll-snap-position\u2462\u2462"},{"id":"ref-for-scroll-snap-position\u2462\u2463"}],"title":"5.2.3. \nUnreachable Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap-position\u2462\u2464"},{"id":"ref-for-scroll-snap-position\u2462\u2465"},{"id":"ref-for-scroll-snap-position\u2462\u2466"},{"id":"ref-for-scroll-snap-position\u2462\u2467"},{"id":"ref-for-scroll-snap-position\u2462\u2468"},{"id":"ref-for-scroll-snap-position\u2463\u24ea"}],"title":"5.3. Scroll Snap Limits: the scroll-snap-stop property"},{"refs":[{"id":"ref-for-scroll-snap-position\u2463\u2460"}],"title":"6. Snapping Mechanics"},{"refs":[{"id":"ref-for-scroll-snap-position\u2463\u2461"},{"id":"ref-for-scroll-snap-position\u2463\u2462"},{"id":"ref-for-scroll-snap-position\u2463\u2463"},{"id":"ref-for-scroll-snap-position\u2463\u2464"},{"id":"ref-for-scroll-snap-position\u2463\u2465"},{"id":"ref-for-scroll-snap-position\u2463\u2466"},{"id":"ref-for-scroll-snap-position\u2463\u2467"},{"id":"ref-for-scroll-snap-position\u2463\u2468"},{"id":"ref-for-scroll-snap-position\u2464\u24ea"},{"id":"ref-for-scroll-snap-position\u2464\u2460"},{"id":"ref-for-scroll-snap-position\u2464\u2461"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-snap-position\u2464\u2462"},{"id":"ref-for-scroll-snap-position\u2464\u2463"},{"id":"ref-for-scroll-snap-position\u2464\u2464"}],"title":"9.1. Changes Since 19 March 2019 CR"},{"refs":[{"id":"ref-for-scroll-snap-position\u2464\u2465"}],"title":"9.4. Changes Since 14 December 2017 CR"},{"refs":[{"id":"ref-for-scroll-snap-position\u2464\u2466"},{"id":"ref-for-scroll-snap-position\u2464\u2467"}],"title":"9.5. Changes Since 24 August 2017 CR"},{"refs":[{"id":"ref-for-scroll-snap-position\u2464\u2468"},{"id":"ref-for-scroll-snap-position\u2465\u24ea"},{"id":"ref-for-scroll-snap-position\u2465\u2460"},{"id":"ref-for-scroll-snap-position\u2465\u2461"},{"id":"ref-for-scroll-snap-position\u2465\u2462"},{"id":"ref-for-scroll-snap-position\u2465\u2463"}],"title":"9.6. Changes Since 20 October 2016 CR"}],"url":"#scroll-snap-position"}, "scroll-snapport": {"dfnID":"scroll-snapport","dfnText":"scroll snapport","external":false,"refSections":[{"refs":[{"id":"ref-for-scroll-snapport"}],"title":"3. Scroll Snap Model"},{"refs":[{"id":"ref-for-scroll-snapport\u2460"}],"title":"4.1.3. \nRe-snapping After Layout Changes"},{"refs":[{"id":"ref-for-scroll-snapport\u2461"},{"id":"ref-for-scroll-snapport\u2462"},{"id":"ref-for-scroll-snapport\u2463"},{"id":"ref-for-scroll-snapport\u2464"},{"id":"ref-for-scroll-snapport\u2465"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"},{"refs":[{"id":"ref-for-scroll-snapport\u2466"},{"id":"ref-for-scroll-snapport\u2467"},{"id":"ref-for-scroll-snapport\u2468"},{"id":"ref-for-scroll-snapport\u2460\u24ea"}],"title":"5.2.1. \nScoping Valid Snap Positions to Visible Boxes"},{"refs":[{"id":"ref-for-scroll-snapport\u2460\u2460"},{"id":"ref-for-scroll-snapport\u2460\u2461"},{"id":"ref-for-scroll-snapport\u2460\u2462"},{"id":"ref-for-scroll-snapport\u2460\u2463"},{"id":"ref-for-scroll-snapport\u2460\u2464"}],"title":"5.2.2. \nSnapping Boxes that Overflow the Scrollport"},{"refs":[{"id":"ref-for-scroll-snapport\u2460\u2465"},{"id":"ref-for-scroll-snapport\u2460\u2466"}],"title":"6.2. Choosing Snap Positions"},{"refs":[{"id":"ref-for-scroll-snapport\u2460\u2467"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-scroll-snapport\u2460\u2468"},{"id":"ref-for-scroll-snapport\u2461\u24ea"}],"title":"Flow-relative Longhands for scroll-padding"}],"url":"#scroll-snapport"}, "strictness-value": {"dfnID":"strictness-value","dfnText":"strictness values","external":false,"refSections":[],"url":"#strictness-value"}, "valdef-scroll-padding-auto": {"dfnID":"valdef-scroll-padding-auto","dfnText":"auto","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-padding-auto"}],"title":"4.2. Scroll Snapport: the scroll-padding property"},{"refs":[{"id":"ref-for-valdef-scroll-padding-auto\u2460"}],"title":"Physical Longhands for scroll-padding"},{"refs":[{"id":"ref-for-valdef-scroll-padding-auto\u2461"}],"title":"Flow-relative Longhands for scroll-padding"},{"refs":[{"id":"ref-for-valdef-scroll-padding-auto\u2462"}],"title":"9.3. Changes Since 14 August 2018 CR"},{"refs":[{"id":"ref-for-valdef-scroll-padding-auto\u2463"}],"title":"9.4. Changes Since 14 December 2017 CR"}],"url":"#valdef-scroll-padding-auto"}, "valdef-scroll-padding-length-percentage-0": {"dfnID":"valdef-scroll-padding-length-percentage-0","dfnText":"<length-percentage [0,\u221e]>","external":false,"refSections":[],"url":"#valdef-scroll-padding-length-percentage-0"}, "valdef-scroll-snap-align-center": {"dfnID":"valdef-scroll-snap-align-center","dfnText":"center","external":false,"refSections":[],"url":"#valdef-scroll-snap-align-center"}, "valdef-scroll-snap-align-end": {"dfnID":"valdef-scroll-snap-align-end","dfnText":"end","external":false,"refSections":[],"url":"#valdef-scroll-snap-align-end"}, "valdef-scroll-snap-align-none": {"dfnID":"valdef-scroll-snap-align-none","dfnText":"none","external":false,"refSections":[],"url":"#valdef-scroll-snap-align-none"}, "valdef-scroll-snap-align-start": {"dfnID":"valdef-scroll-snap-align-start","dfnText":"start","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-align-start"}],"title":"5.2. Scroll Snapping Alignment: the scroll-snap-align property"}],"url":"#valdef-scroll-snap-align-start"}, "valdef-scroll-snap-stop-always": {"dfnID":"valdef-scroll-snap-stop-always","dfnText":"always","external":false,"refSections":[],"url":"#valdef-scroll-snap-stop-always"}, "valdef-scroll-snap-stop-normal": {"dfnID":"valdef-scroll-snap-stop-normal","dfnText":"normal","external":false,"refSections":[],"url":"#valdef-scroll-snap-stop-normal"}, "valdef-scroll-snap-type-block": {"dfnID":"valdef-scroll-snap-type-block","dfnText":"block","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-block"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"}],"url":"#valdef-scroll-snap-type-block"}, "valdef-scroll-snap-type-both": {"dfnID":"valdef-scroll-snap-type-both","dfnText":"both","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-both"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"}],"url":"#valdef-scroll-snap-type-both"}, "valdef-scroll-snap-type-inline": {"dfnID":"valdef-scroll-snap-type-inline","dfnText":"inline","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-inline"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"}],"url":"#valdef-scroll-snap-type-inline"}, "valdef-scroll-snap-type-mandatory": {"dfnID":"valdef-scroll-snap-type-mandatory","dfnText":"mandatory","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-mandatory"},{"id":"ref-for-valdef-scroll-snap-type-mandatory\u2460"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"},{"refs":[{"id":"ref-for-valdef-scroll-snap-type-mandatory\u2461"}],"title":"6.2. Choosing Snap Positions"}],"url":"#valdef-scroll-snap-type-mandatory"}, "valdef-scroll-snap-type-none": {"dfnID":"valdef-scroll-snap-type-none","dfnText":"none","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-none"},{"id":"ref-for-valdef-scroll-snap-type-none\u2460"},{"id":"ref-for-valdef-scroll-snap-type-none\u2461"},{"id":"ref-for-valdef-scroll-snap-type-none\u2462"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"}],"url":"#valdef-scroll-snap-type-none"}, "valdef-scroll-snap-type-proximity": {"dfnID":"valdef-scroll-snap-type-proximity","dfnText":"proximity","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-proximity"}],"title":"4.1. Scroll Snapping Rules: the scroll-snap-type property"},{"refs":[{"id":"ref-for-valdef-scroll-snap-type-proximity\u2460"},{"id":"ref-for-valdef-scroll-snap-type-proximity\u2461"}],"title":"4.1.2. \nScroll Snap Strictness: the none, proximity, and mandatory values"}],"url":"#valdef-scroll-snap-type-proximity"}, "valdef-scroll-snap-type-x": {"dfnID":"valdef-scroll-snap-type-x","dfnText":"x","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-x"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"}],"url":"#valdef-scroll-snap-type-x"}, "valdef-scroll-snap-type-y": {"dfnID":"valdef-scroll-snap-type-y","dfnText":"y","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-y"}],"title":"4.1.1. \nScroll Snap Axis: the x, y, block, inline, and both values"}],"url":"#valdef-scroll-snap-type-y"}, }; document.addEventListener("DOMContentLoaded", ()=>{ genAllDfnPanels(); document.body.addEventListener("click", (e) => { // If not handled already, just hide all dfn panels. hideAllDfnPanels(); }); }); window.addEventListener("resize", () => { // Pin any visible dfn panel queryAll(".dfn-panel.on, .dfn-panel.activated").forEach(el=>positionDfnPanel(el)); }); function genAllDfnPanels() { for(const panelData of Object.values(dfnPanelData)) { const dfnID = panelData.dfnID; const dfn = document.getElementById(dfnID); if(!dfn) { console.log(`Can't find dfn#${dfnID}.`, panelData); continue; } dfn.panelData = panelData; insertDfnPopupAction(dfn); } } function genDfnPanel(dfn, { dfnID, url, dfnText, refSections, external }) { const dfnPanel = mk.aside({ class: "dfn-panel on", id: `infopanel-for-${dfnID}`, "data-for": dfnID, "aria-labelled-by":`infopaneltitle-for-${dfnID}`, }, mk.span({id:`infopaneltitle-for-${dfnID}`, style:"display:none"}, `Info about the '${dfnText}' ${external?"external":""} reference.`), mk.a({href:url, class:"dfn-link"}, url), refSections.length == 0 ? [] : mk.b({}, "Referenced in:"), mk.ul({}, ...refSections.map(section=> mk.li({}, ...section.refs.map((ref, refI)=> [ mk.a({ href: `#${ref.id}` }, (refI == 0) ? section.title : `(${refI + 1})` ), " ", ] ), ), ), ), genLinkingSyntaxes(dfn), ); dfnPanel.addEventListener('click', (event) => { if (event.target.nodeName == 'A') { scrollToTargetAndHighlight(event); pinDfnPanel(dfnPanel); } event.stopPropagation(); refocusOnTarget(event); }); dfnPanel.addEventListener('keydown', (event) => { if(event.keyCode == 27) { // Escape key hideDfnPanel({dfnPanel}); event.stopPropagation(); event.preventDefault(); } }); dfnPanel.dfn = dfn; dfn.dfnPanel = dfnPanel; return dfnPanel; } function hideAllDfnPanels() { // Delete the currently-active dfn panel. queryAll(".dfn-panel").forEach(dfnPanel=>hideDfnPanel({dfnPanel})); } function showDfnPanel(dfn) { hideAllDfnPanels(); // Only display one at a time. dfn.setAttribute("aria-expanded", "true"); const dfnPanel = genDfnPanel(dfn, dfn.panelData); // Give the dfn a unique tabindex, and then // give all the tabbable panel bits successive indexes. let tabIndex = 100; dfn.tabIndex = tabIndex++; const tabbable = dfnPanel.querySelectorAll(":is(a, button)"); for (const el of tabbable) { el.tabIndex = tabIndex++; } append(document.body, dfnPanel); positionDfnPanel(dfnPanel); } function positionDfnPanel(dfnPanel) { const dfn = dfnPanel.dfn; const dfnPos = getBounds(dfn); dfnPanel.style.top = dfnPos.bottom + "px"; dfnPanel.style.left = dfnPos.left + "px"; const panelPos = dfnPanel.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, dfnPos.left - overflowAmount); dfnPanel.style.left = newLeft + "px"; } } function pinDfnPanel(dfnPanel) { // Switch it to "activated" state, which pins it. dfnPanel.classList.add("activated"); dfnPanel.style.position = "fixed"; dfnPanel.style.left = null; dfnPanel.style.top = null; } function hideDfnPanel({dfn, dfnPanel}) { if(!dfnPanel) dfnPanel = dfn.dfnPanel; if(!dfn) dfn = dfnPanel.dfn; dfn.dfnPanel = undefined; dfnPanel.dfn = undefined; dfn.setAttribute("aria-expanded", "false"); dfn.tabIndex = undefined; dfnPanel.remove() } function toggleDfnPanel(dfn) { if(dfn.dfnPanel) { hideDfnPanel(dfn); } else { showDfnPanel(dfn); } } function insertDfnPopupAction(dfn) { dfn.setAttribute('role', 'button'); dfn.setAttribute('aria-expanded', 'false') dfn.tabIndex = 0; dfn.classList.add('has-dfn-panel'); dfn.addEventListener('click', (event) => { toggleDfnPanel(dfn); event.stopPropagation(); }); dfn.addEventListener('keypress', (event) => { const kc = event.keyCode; // 32->Space, 13->Enter if(kc == 32 || kc == 13) { toggleDfnPanel(dfn); event.stopPropagation(); event.preventDefault(); } }); } function refocusOnTarget(event) { const target = event.target; setTimeout(() => { // Refocus on the event.target element. // This is needed after browser scrolls to the destination. target.focus(); }); } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function scrollToTargetAndHighlight(event) { let hash = event.target.hash; if (hash) { hash = decodeURIComponent(hash.substring(1)); const dest = document.getElementById(hash); if (dest) { dest.classList.add('highlighted'); setTimeout(() => dest.classList.remove('highlighted'), 1000); } } } // Functions, divided by link type, that wrap an autolink's // contents with the appropriate outer syntax. // Alternately, a string naming another type they format // the same as. function needsFor(type) { switch(type) { case "descriptor": case "value": case "element-attr": case "attr-value": case "element-state": case "method": case "constructor": case "argument": case "attribute": case "const": case "dict-member": case "event": case "enum-value": case "stringifier": case "serializer": case "iterator": case "maplike": case "setlike": case "state": case "mode": case "context": case "facet": return true; default: return false; } } function refusesFor(type) { switch(type) { case "property": case "element": case "interface": case "namespace": case "callback": case "dictionary": case "enum": case "exception": case "typedef": case "http-header": case "permission": return true; default: return false; } } function linkFormatterFromType(type) { switch(type) { case 'scheme': case 'permission': case 'dfn': return (text) => `[=${text}=]`; case 'abstract-op': return (text) => `[\$${text}\$]`; case 'function': case 'at-rule': case 'selector': case 'value': return (text) => `''${text}''`; case 'http-header': return (text) => `[:${text}:]`; case 'interface': case 'constructor': case 'method': case 'argument': case 'attribute': case 'callback': case 'dictionary': case 'dict-member': case 'enum': case 'enum-value': case 'exception': case 'const': case 'typedef': case 'stringifier': case 'serializer': case 'iterator': case 'maplike': case 'setlike': case 'extended-attribute': case 'event': case 'idl': return (text) => `{{${text}}}`; case 'element-state': case 'element-attr': case 'attr-value': case 'element': return (element) => `<{${element}}>`; case 'grammar': return (text) => `${text} (within a <pre class=prod>)`; case 'type': return (text)=> `<<${text}>>`; case 'descriptor': case 'property': return (text) => `'${text}'`; default: return; }; }; function genLinkingSyntaxes(dfn) { if(dfn.tagName != "DFN") return; const type = dfn.getAttribute('data-dfn-type'); if(!type) { console.log(`<dfn> doesn't have a data-dfn-type:`, dfn); return []; } // Return a function that wraps link text based on the type const linkFormatter = linkFormatterFromType(type); if(!linkFormatter) { console.log(`<dfn> has an unknown data-dfn-type:`, dfn); return []; } let ltAlts; if(dfn.hasAttribute('data-lt')) { ltAlts = dfn.getAttribute('data-lt') .split("|") .map(x=>x.trim()); } else { ltAlts = [dfn.textContent.trim()]; } if(type == "type") { // lt of "<foo>", but "foo" is the interior; // <<foo/bar>> is how you write it with a for, // not <foo/<bar>> or whatever. for(var i = 0; i < ltAlts.length; i++) { const lt = ltAlts[i]; const match = /<(.*)>/.exec(lt); if(match) { ltAlts[i] = match[1]; } } } let forAlts; if(dfn.hasAttribute('data-dfn-for')) { forAlts = dfn.getAttribute('data-dfn-for') .split(",") .map(x=>x.trim()); } else { forAlts = ['']; } let linkingSyntaxes = []; if(!needsFor(type)) { for(const lt of ltAlts) { linkingSyntaxes.push(linkFormatter(lt)); } } if(!refusesFor(type)) { for(const f of forAlts) { linkingSyntaxes.push(linkFormatter(`${f}/${ltAlts[0]}`)) } } return [ mk.b({}, 'Possible linking syntaxes:'), mk.ul({}, ...linkingSyntaxes.map(link => { const copyLink = async () => await navigator.clipboard.writeText(link); return mk.li({}, mk.div({ class: 'link-item' }, mk.button({ class: 'copy-icon', title: 'Copy', type: 'button', _onclick: copyLink, tabindex: 0, }, mk.span({ class: 'icon' }) ), mk.span({}, link) ) ); }) ) ]; } } </script> <script>/* Boilerplate: script-link-titles */ "use strict"; { let linkTitleData = { "https://drafts.csswg.org/css-values-4/#length-value": "Expands to: advance measure | cap | ch | cm | dvb | dvh | dvi | dvmax | dvmin | dvw | em | ex | ic | in | lh | lvb | lvh | lvi | lvmax | lvmin | lvw | mm | pc | pt | px | rcap | rch | rem | rex | ric | rlh | svb | svh | svi | svmax | svmin | svw | vb | vh | vi | vmax | vmin | vw", }; function setTypeTitles() { for(let el of document.querySelectorAll("a[href]")) { if(el.href in linkTitleData && !el.hasAttribute("title")) { el.setAttribute("title", linkTitleData[el.href]); } } } document.addEventListener("DOMContentLoaded", setTypeTitles); } </script> <script>/* Boilerplate: script-position-annos */ "use strict"; { function repositionAnnoPanels(){ const panels = [...document.querySelectorAll("[data-anno-for]")]; hydratePanels(panels); let vSoFar = 0; for(const panel of panels.sort(cmpTops)) { if(panel.top < vSoFar) { panel.top = vSoFar; panel.style.top = vSoFar + "px"; } vSoFar = panel.top + panel.height + 15; } } function hydratePanels(panels) { const main = document.querySelector("main"); let mainRect; if(main) mainRect = main.getBoundingClientRect(); // First display them all, if they're not already visible. for(const panel of panels) { panel.classList.remove("unpositioned"); } // Measure them all for(const panel of panels) { const dfn = document.getElementById(panel.getAttribute("data-anno-for")); if(!dfn) { console.log("Can't find the annotation panel target:", panel); continue; } panel.dfn = dfn; panel.top = window.scrollY + dfn.getBoundingClientRect().top; let panelRect = panel.getBoundingClientRect(); panel.height = panelRect.height; if(main) { panel.overlappingMain = panelRect.left < mainRect.right; } else { panel.overlappingMain = false; } } // And finally position them for(const panel of panels) { const dfn = panel.dfn; if(!dfn) continue; panel.style.top = panel.top + "px"; panel.classList.toggle("overlapping-main", panel.overlappingMain); } } function cmpTops(a,b) { return a.top - b.top; } window.addEventListener("load", repositionAnnoPanels); window.addEventListener("resize", repositionAnnoPanels); } </script> <script>/* Boilerplate: script-ref-hints */ "use strict"; { let refsData = { "#axis-lock": {"displayText":"axis-lock","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"axis-lock","type":"dfn","url":"#axis-lock"}, "#captures-snap-positions": {"displayText":"captures snap positions","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"captures snap positions","type":"dfn","url":"#captures-snap-positions"}, "#intended-direction": {"displayText":"intended direction","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"intended direction","type":"dfn","url":"#intended-direction"}, "#intended-direction-and-end-position": {"displayText":"intended direction and end position","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"intended direction and end position","type":"dfn","url":"#intended-direction-and-end-position"}, "#intended-end-position": {"displayText":"intended end position","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"intended end position","type":"dfn","url":"#intended-end-position"}, "#natural-end-point": {"displayText":"natural end-point","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"natural end-point","type":"dfn","url":"#natural-end-point"}, "#optimal-viewing-region": {"displayText":"optimal viewing region","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"optimal viewing region","type":"dfn","url":"#optimal-viewing-region"}, "#propdef-scroll-margin": {"displayText":"scroll-margin","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin","type":"property","url":"#propdef-scroll-margin"}, "#propdef-scroll-margin-block": {"displayText":"scroll-margin-block","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-block","type":"property","url":"#propdef-scroll-margin-block"}, "#propdef-scroll-margin-block-end": {"displayText":"scroll-margin-block-end","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-block-end","type":"property","url":"#propdef-scroll-margin-block-end"}, "#propdef-scroll-margin-block-start": {"displayText":"scroll-margin-block-start","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-block-start","type":"property","url":"#propdef-scroll-margin-block-start"}, "#propdef-scroll-margin-bottom": {"displayText":"scroll-margin-bottom","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-bottom","type":"property","url":"#propdef-scroll-margin-bottom"}, "#propdef-scroll-margin-inline": {"displayText":"scroll-margin-inline","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-inline","type":"property","url":"#propdef-scroll-margin-inline"}, "#propdef-scroll-margin-inline-end": {"displayText":"scroll-margin-inline-end","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-inline-end","type":"property","url":"#propdef-scroll-margin-inline-end"}, "#propdef-scroll-margin-inline-start": {"displayText":"scroll-margin-inline-start","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-inline-start","type":"property","url":"#propdef-scroll-margin-inline-start"}, "#propdef-scroll-margin-left": {"displayText":"scroll-margin-left","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-left","type":"property","url":"#propdef-scroll-margin-left"}, "#propdef-scroll-margin-right": {"displayText":"scroll-margin-right","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-right","type":"property","url":"#propdef-scroll-margin-right"}, "#propdef-scroll-margin-top": {"displayText":"scroll-margin-top","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-margin-top","type":"property","url":"#propdef-scroll-margin-top"}, "#propdef-scroll-padding": {"displayText":"scroll-padding","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding","type":"property","url":"#propdef-scroll-padding"}, "#propdef-scroll-padding-block": {"displayText":"scroll-padding-block","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-block","type":"property","url":"#propdef-scroll-padding-block"}, "#propdef-scroll-padding-block-end": {"displayText":"scroll-padding-block-end","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-block-end","type":"property","url":"#propdef-scroll-padding-block-end"}, "#propdef-scroll-padding-block-start": {"displayText":"scroll-padding-block-start","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-block-start","type":"property","url":"#propdef-scroll-padding-block-start"}, "#propdef-scroll-padding-bottom": {"displayText":"scroll-padding-bottom","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-bottom","type":"property","url":"#propdef-scroll-padding-bottom"}, "#propdef-scroll-padding-inline": {"displayText":"scroll-padding-inline","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-inline","type":"property","url":"#propdef-scroll-padding-inline"}, "#propdef-scroll-padding-inline-end": {"displayText":"scroll-padding-inline-end","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-inline-end","type":"property","url":"#propdef-scroll-padding-inline-end"}, "#propdef-scroll-padding-inline-start": {"displayText":"scroll-padding-inline-start","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-inline-start","type":"property","url":"#propdef-scroll-padding-inline-start"}, "#propdef-scroll-padding-left": {"displayText":"scroll-padding-left","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-left","type":"property","url":"#propdef-scroll-padding-left"}, "#propdef-scroll-padding-right": {"displayText":"scroll-padding-right","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-right","type":"property","url":"#propdef-scroll-padding-right"}, "#propdef-scroll-padding-top": {"displayText":"scroll-padding-top","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-padding-top","type":"property","url":"#propdef-scroll-padding-top"}, "#propdef-scroll-snap-align": {"displayText":"scroll-snap-align","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-snap-align","type":"property","url":"#propdef-scroll-snap-align"}, "#propdef-scroll-snap-stop": {"displayText":"scroll-snap-stop","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-snap-stop","type":"property","url":"#propdef-scroll-snap-stop"}, "#propdef-scroll-snap-type": {"displayText":"scroll-snap-type","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll-snap-type","type":"property","url":"#propdef-scroll-snap-type"}, "#scroll-snap": {"displayText":"snap","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"snap","type":"dfn","url":"#scroll-snap"}, "#scroll-snap-area": {"displayText":"scroll snap area","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll snap area","type":"dfn","url":"#scroll-snap-area"}, "#scroll-snap-container": {"displayText":"scroll snap container","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll snap container","type":"dfn","url":"#scroll-snap-container"}, "#scroll-snap-position": {"displayText":"scroll snap position","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"scroll snap position","type":"dfn","url":"#scroll-snap-position"}, "#scroll-snapport": {"displayText":"snapport","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"snapport","type":"dfn","url":"#scroll-snapport"}, "#valdef-scroll-padding-auto": {"displayText":"auto","export":true,"for_":["scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"auto","type":"value","url":"#valdef-scroll-padding-auto"}, "#valdef-scroll-snap-align-start": {"displayText":"start","export":true,"for_":["scroll-snap-align"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"start","type":"value","url":"#valdef-scroll-snap-align-start"}, "#valdef-scroll-snap-type-block": {"displayText":"block","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"block","type":"value","url":"#valdef-scroll-snap-type-block"}, "#valdef-scroll-snap-type-both": {"displayText":"both","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"both","type":"value","url":"#valdef-scroll-snap-type-both"}, "#valdef-scroll-snap-type-inline": {"displayText":"inline","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"inline","type":"value","url":"#valdef-scroll-snap-type-inline"}, "#valdef-scroll-snap-type-mandatory": {"displayText":"mandatory","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"mandatory","type":"value","url":"#valdef-scroll-snap-type-mandatory"}, "#valdef-scroll-snap-type-none": {"displayText":"none","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"none","type":"value","url":"#valdef-scroll-snap-type-none"}, "#valdef-scroll-snap-type-proximity": {"displayText":"proximity","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"proximity","type":"value","url":"#valdef-scroll-snap-type-proximity"}, "#valdef-scroll-snap-type-x": {"displayText":"x","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"x","type":"value","url":"#valdef-scroll-snap-type-x"}, "#valdef-scroll-snap-type-y": {"displayText":"y","export":true,"for_":["scroll-snap-type"],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"local","text":"y","type":"value","url":"#valdef-scroll-snap-type-y"}, "https://dom.spec.whatwg.org/#concept-tree-order": {"displayText":"tree order","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"tree order","type":"dfn","url":"https://dom.spec.whatwg.org/#concept-tree-order"}, "https://drafts.csswg.org/css-align-3/#alignment-container": {"displayText":"alignment container","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-align","spec":"css-align-3","status":"current","text":"alignment container","type":"dfn","url":"https://drafts.csswg.org/css-align-3/#alignment-container"}, "https://drafts.csswg.org/css-align-3/#alignment-subject": {"displayText":"alignment subject","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-align","spec":"css-align-3","status":"current","text":"alignment subject","type":"dfn","url":"https://drafts.csswg.org/css-align-3/#alignment-subject"}, "https://drafts.csswg.org/css-box-4/#propdef-margin": {"displayText":"margin","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-box","spec":"css-box-4","status":"current","text":"margin","type":"property","url":"https://drafts.csswg.org/css-box-4/#propdef-margin"}, "https://drafts.csswg.org/css-box-4/#propdef-padding": {"displayText":"padding","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-box","spec":"css-box-4","status":"current","text":"padding","type":"property","url":"https://drafts.csswg.org/css-box-4/#propdef-padding"}, "https://drafts.csswg.org/css-cascade-5/#longhand": {"displayText":"longhand","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"longhand","type":"dfn","url":"https://drafts.csswg.org/css-cascade-5/#longhand"}, "https://drafts.csswg.org/css-cascade-5/#shorthand-property": {"displayText":"shorthand property","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"shorthand property","type":"dfn","url":"https://drafts.csswg.org/css-cascade-5/#shorthand-property"}, "https://drafts.csswg.org/css-display-4/#containing-block-chain": {"displayText":"containing block chain","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-display","spec":"css-display-4","status":"current","text":"containing block chain","type":"dfn","url":"https://drafts.csswg.org/css-display-4/#containing-block-chain"}, "https://drafts.csswg.org/css-logical-1/#inset-properties": {"displayText":"inset properties","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-logical","spec":"css-logical-1","status":"current","text":"inset properties","type":"dfn","url":"https://drafts.csswg.org/css-logical-1/#inset-properties"}, "https://drafts.csswg.org/css-overflow-3/#propdef-overflow": {"displayText":"overflow","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"overflow","type":"property","url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow"}, "https://drafts.csswg.org/css-overflow-3/#propdef-scroll-behavior": {"displayText":"scroll-behavior","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"scroll-behavior","type":"property","url":"https://drafts.csswg.org/css-overflow-3/#propdef-scroll-behavior"}, "https://drafts.csswg.org/css-overflow-3/#scroll-container": {"displayText":"scroll container","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"scroll container","type":"dfn","url":"https://drafts.csswg.org/css-overflow-3/#scroll-container"}, "https://drafts.csswg.org/css-overflow-3/#scroll-position": {"displayText":"scroll position","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"scroll position","type":"dfn","url":"https://drafts.csswg.org/css-overflow-3/#scroll-position"}, "https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region": {"displayText":"scrollable overflow area","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"scrollable overflow area","type":"dfn","url":"https://drafts.csswg.org/css-overflow-3/#scrollable-overflow-region"}, "https://drafts.csswg.org/css-overflow-3/#scrollport": {"displayText":"scrollport","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"scrollport","type":"dfn","url":"https://drafts.csswg.org/css-overflow-3/#scrollport"}, "https://drafts.csswg.org/css-position-3/#fixed-position": {"displayText":"fixed-positioned box","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-position","spec":"css-position-3","status":"current","text":"fixed-positioned box","type":"dfn","url":"https://drafts.csswg.org/css-position-3/#fixed-position"}, "https://drafts.csswg.org/css-position-3/#propdef-inset": {"displayText":"inset","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-position","spec":"css-position-3","status":"current","text":"inset","type":"property","url":"https://drafts.csswg.org/css-position-3/#propdef-inset"}, "https://drafts.csswg.org/css-pseudo-4/#selectordef-after": {"displayText":"::after","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-pseudo","spec":"css-pseudo-4","status":"current","text":"::after","type":"selector","url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-after"}, "https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter": {"displayText":"::first-letter","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-pseudo","spec":"css-pseudo-4","status":"current","text":"::first-letter","type":"selector","url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-first-letter"}, "https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line": {"displayText":"::first-line","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-pseudo","spec":"css-pseudo-4","status":"current","text":"::first-line","type":"selector","url":"https://drafts.csswg.org/css-pseudo-4/#selectordef-first-line"}, "https://drafts.csswg.org/css-values-4/#comb-one": {"displayText":"|","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"|","type":"grammar","url":"https://drafts.csswg.org/css-values-4/#comb-one"}, "https://drafts.csswg.org/css-values-4/#css-wide-keywords": {"displayText":"CSS-wide keywords","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"css-wide keywords","type":"dfn","url":"https://drafts.csswg.org/css-values-4/#css-wide-keywords"}, "https://drafts.csswg.org/css-values-4/#length-value": {"displayText":"<length>","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"<length>","type":"type","url":"https://drafts.csswg.org/css-values-4/#length-value"}, "https://drafts.csswg.org/css-values-4/#mult-num-range": {"displayText":"{A,B}","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"{a,b}","type":"grammar","url":"https://drafts.csswg.org/css-values-4/#mult-num-range"}, "https://drafts.csswg.org/css-values-4/#mult-opt": {"displayText":"?","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"?","type":"grammar","url":"https://drafts.csswg.org/css-values-4/#mult-opt"}, "https://drafts.csswg.org/css-values-4/#percentage-value": {"displayText":"<percentage>","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"<percentage>","type":"type","url":"https://drafts.csswg.org/css-values-4/#percentage-value"}, "https://drafts.csswg.org/css-values-4/#typedef-length-percentage": {"displayText":"<length-percentage>","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-values","spec":"css-values-4","status":"current","text":"<length-percentage>","type":"type","url":"https://drafts.csswg.org/css-values-4/#typedef-length-percentage"}, "https://drafts.csswg.org/css-writing-modes-4/#block-axis": {"displayText":"block axis","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-writing-modes","spec":"css-writing-modes-4","status":"current","text":"block axis","type":"dfn","url":"https://drafts.csswg.org/css-writing-modes-4/#block-axis"}, "https://drafts.csswg.org/css-writing-modes-4/#inline-axis": {"displayText":"inline axis","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-writing-modes","spec":"css-writing-modes-4","status":"current","text":"inline axis","type":"dfn","url":"https://drafts.csswg.org/css-writing-modes-4/#inline-axis"}, "https://drafts.csswg.org/css-writing-modes-4/#writing-mode": {"displayText":"writing mode","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-writing-modes","spec":"css-writing-modes-4","status":"current","text":"writing mode","type":"dfn","url":"https://drafts.csswg.org/css-writing-modes-4/#writing-mode"}, "https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview": {"displayText":"scrollIntoView()","export":true,"for_":["Element"],"level":"1","normative":true,"shortname":"cssom-view","spec":"cssom-view-1","status":"current","text":"scrollIntoView()","type":"method","url":"https://drafts.csswg.org/cssom-view-1/#dom-element-scrollintoview"}, "https://drafts.csswg.org/cssom-view-1/#dom-window-scrollby": {"displayText":"scrollBy()","export":true,"for_":["Window"],"level":"1","normative":true,"shortname":"cssom-view","spec":"cssom-view-1","status":"current","text":"scrollBy()","type":"method","url":"https://drafts.csswg.org/cssom-view-1/#dom-window-scrollby"}, "https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto": {"displayText":"scrollTo()","export":true,"for_":["Window"],"level":"1","normative":true,"shortname":"cssom-view","spec":"cssom-view-1","status":"current","text":"scrollTo()","type":"method","url":"https://drafts.csswg.org/cssom-view-1/#dom-window-scrollto"}, "https://drafts.csswg.org/selectors-4/#target-pseudo": {"displayText":":target","export":true,"for_":[],"level":"4","normative":true,"shortname":"selectors","spec":"selectors-4","status":"current","text":":target","type":"selector","url":"https://drafts.csswg.org/selectors-4/#target-pseudo"}, "https://html.spec.whatwg.org/multipage/sections.html#the-body-element": {"displayText":"body","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"body","type":"element","url":"https://html.spec.whatwg.org/multipage/sections.html#the-body-element"}, "https://html.spec.whatwg.org/multipage/sections.html#the-section-element": {"displayText":"section","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"section","type":"element","url":"https://html.spec.whatwg.org/multipage/sections.html#the-section-element"}, }; function mkRefHint(link, ref) { const linkText = link.textContent; let dfnTextElements = ''; if (ref.displayText.toLowerCase() != linkText.toLowerCase()) { // Give the original term if it's being displayed in a different way. // But allow casing differences, they're insignificant. dfnTextElements = mk.li({}, mk.b({}, "Term: "), mk.span({}, ref.displayText) ); } const forList = ref.for_; let forListElements; if(forList.length == 0) { forListElements = []; } else if(forList.length == 1) { forListElements = mk.li({}, mk.b({}, "For: "), mk.span({}, forList[0]), ); } else { forListElements = mk.li({}, mk.b({}, "For: "), mk.ul({}, ...forList.map(forItem => mk.li({}, mk.span({}, forItem) ), ), ), ); } const url = ref.url; const safeUrl = encodeURIComponent(url); const hintPanel = mk.aside({ class: "ref-hint", id: `ref-hint-for-${safeUrl}`, "data-for": url, "aria-labelled-by": `ref-hint-for-${safeUrl}`, }, mk.ul({}, dfnTextElements, mk.li({}, mk.b({}, "URL: "), mk.a({ href: url, class: "ref" }, url), ), mk.li({}, mk.b({}, "Type: "), mk.span({}, `${ref.type}`), ), mk.li({}, mk.b({}, "Spec: "), mk.span({}, `${ref.spec ? ref.spec : ''}`), ), forListElements ), ); hintPanel.forLink = link; setupRefHintEventListeners(link, hintPanel); return hintPanel; } function hideAllRefHints() { queryAll(".ref-hint").forEach(el=>hideRefHint(el)); } function hideRefHint(refHint) { const link = refHint.forLink; link.setAttribute("aria-expanded", "false"); if(refHint.teardownEventListeners) { refHint.teardownEventListeners(); } refHint.remove(); } function showRefHint(link) { if(link.classList.contains("dfn-link")) return; const url = link.getAttribute("href"); const ref = refsData[url]; if(!ref) return; hideAllRefHints(); // Only display one at this time. const refHint = mkRefHint(link, ref); append(document.body, refHint); link.setAttribute("aria-expanded", "true"); positionRefHint(refHint); } function setupRefHintEventListeners(link, refHint) { if (refHint.teardownEventListeners) return; // Add event handlers to hide the refHint after the user moves away // from both the link and refHint, if not hovering either within one second. let timeout = null; const startHidingRefHint = (event) => { if (timeout) { clearTimeout(timeout); } timeout = setTimeout(() => { hideRefHint(refHint); }, 1000); } const resetHidingRefHint = (event) => { if (timeout) clearTimeout(timeout); timeout = null; }; link.addEventListener("mouseleave", startHidingRefHint); link.addEventListener("mouseenter", resetHidingRefHint); link.addEventListener("blur", startHidingRefHint); link.addEventListener("focus", resetHidingRefHint); refHint.addEventListener("mouseleave", startHidingRefHint); refHint.addEventListener("mouseenter", resetHidingRefHint); refHint.addEventListener("blur", startHidingRefHint); refHint.addEventListener("focus", resetHidingRefHint); refHint.teardownEventListeners = () => { // remove event listeners resetHidingRefHint(); link.removeEventListener("mouseleave", startHidingRefHint); link.removeEventListener("mouseenter", resetHidingRefHint); link.removeEventListener("blur", startHidingRefHint); link.removeEventListener("focus", resetHidingRefHint); refHint.removeEventListener("mouseleave", startHidingRefHint); refHint.removeEventListener("mouseenter", resetHidingRefHint); refHint.removeEventListener("blur", startHidingRefHint); refHint.removeEventListener("focus", resetHidingRefHint); }; } function positionRefHint(refHint) { const link = refHint.forLink; const linkPos = getBounds(link); refHint.style.top = linkPos.bottom + "px"; refHint.style.left = linkPos.left + "px"; const panelPos = refHint.getBoundingClientRect(); const panelMargin = 8; const maxRight = document.body.parentNode.clientWidth - panelMargin; if (panelPos.right > maxRight) { const overflowAmount = panelPos.right - maxRight; const newLeft = Math.max(panelMargin, linkPos.left - overflowAmount); refHint.style.left = newLeft + "px"; } } // TODO: shared util // Returns the root-level absolute position {left and top} of element. function getBounds(el, relativeTo=document.body) { const relativeRect = relativeTo.getBoundingClientRect(); const elRect = el.getBoundingClientRect(); const top = elRect.top - relativeRect.top; const left = elRect.left - relativeRect.left; return { top, left, bottom: top + elRect.height, right: left + elRect.width, } } function showRefHintListener(e) { // If the target isn't in a link (or is a link), // just ignore it. let link = e.target.closest("a"); if(!link) return; // If the target is in a ref-hint panel // (aka a link in the already-open one), // also just ignore it. if(link.closest(".ref-hint")) return; // Otherwise, show the panel for the link. showRefHint(link); } function hideAllHintsListener(e) { // If the click is inside a ref-hint panel, ignore it. if(e.target.closest(".ref-hint")) return; // Otherwise, close all the current panels. hideAllRefHints(); } document.addEventListener("DOMContentLoaded", () => { document.body.addEventListener("mousedown", showRefHintListener); document.body.addEventListener("focus", showRefHintListener); document.body.addEventListener("click", hideAllHintsListener); }); window.addEventListener("resize", () => { // Hide any open ref hint. hideAllRefHints(); }); } </script>