CINXE.COM
CSS Spatial Navigation 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 Spatial Navigation 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 b25686b9f, updated Fri Mar 14 14:15:20 2025 -0700" name="generator"> <link href="https://www.w3.org/TR/css-nav-1/" rel="canonical"> <link href="https://drafts.csswg.org/csslogo.ico" rel="icon"> <meta content="086852dd056fd3944f8ba6f2f9bf05edcb9574e6" 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> code.key { border: solid 1px; border-radius: 0.5ch; padding: 1px 5px; } .output { background: white; padding: 1em; } </style> <style> #api-check:checked ~ .api, #api-check:checked ~ * .api { display: none; } #cssapi-check:checked ~ .cssapi, #cssapi-check:checked ~ * .cssapi { display: none; } #verbose-check:checked ~ .verbose, #verbose-check:checked ~ * .verbose { display: none; } </style> <style> #example-cal table, #example-cal td, #example-cal th { border-collapse: collapse; border: solid 1px; } #example-cal th { text-align: center; } #example-cal td { width: 12.5%; } #example-cal { display: grid; grid-template-columns: auto 1fr auto; } #example-cal button { align-self: center; } /* For browsers that don't support grid */ #example-cal table { display:inline-table; vertical-align: middle; } </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-idl-highlighting */ pre.idl.highlight { background: var(--borderedblock-bg, var(--def-bg)); } </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-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-var-click-highlighting */ /* Colors were chosen in Lab using https://nixsensor.com/free-color-converter/ D50 2deg illuminant, L in [0,100], a and b in [-128, 128] 0 = lab(85,0,85) 1 = lab(85,80,30) 2 = lab(85,-40,40) 3 = lab(85,-50,0) 4 = lab(85,5,15) 5 = lab(85,-10,-50) 6 = lab(85,35,-15) For darkmode: 0 = oklab(50% 0% 108%) 1 = oklab(50% -51% 51%) 2 = oklab(50% -64% -20%) 3 = oklab(50% 6% 19%) 4 = oklab(50% -12% -64%) 5 = oklab(50% 44% -19%) 6 = oklab(50% 102% 38%) */ [data-algorithm] var { cursor: pointer; } var[data-var-color] { background-color: var(--var-bg); box-shadow: 0 0 0 2px var(--var-bg); } var[data-var-color] { --var-bg: #F4D200; } var[data-var-color="1"] { --var-bg: #FF87A2; } var[data-var-color="2"] { --var-bg: #96E885; } var[data-var-color="3"] { --var-bg: #3EEED2; } var[data-var-color="4"] { --var-bg: #EACFB6; } var[data-var-color="5"] { --var-bg: #82DDFF; } var[data-var-color="6"] { --var-vg: #FFBCF2; } @media (prefers-color-scheme: dark) { var[data-var-color] { --var-bg: #bc1a00; } var[data-var-color="1"] { --var-bg: #007f00; } var[data-var-color="2"] { --var-bg: #008698; } var[data-var-color="3"] { --var-bg: #7f5b2b; } var[data-var-color="4"] { --var-bg: #004df3; } var[data-var-color="5"] { --var-bg: #a1248a; } var[data-var-color="6"] { --var-vg: #ff0000; } } </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 Spatial Navigation 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-07-29">29 July 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-nav-1/">https://drafts.csswg.org/css-nav-1/</a> <dt>Latest published version: <dd><a href="https://www.w3.org/TR/css-nav-1/">https://www.w3.org/TR/css-nav-1/</a> <dt>Previous Versions: <dd><a href="https://www.w3.org/TR/2019/WD-css-nav-1-20190423/" rel="prev">https://www.w3.org/TR/2019/WD-css-nav-1-20190423/</a> <dd><a href="https://www.w3.org/TR/2019/WD-css-nav-1-20191126/" rel="prev">https://www.w3.org/TR/2019/WD-css-nav-1-20191126/</a> <dt>Feedback: <dd><a href="https://github.com/w3c/csswg-drafts/labels/css-nav-1">CSSWG Issues Repository</a> <dd><a href="#issues-index">Inline In Spec</a> <dt class="editor">Editors: <dd class="editor p-author h-card vcard" data-editor-id="79168"><a class="p-name fn u-email email" href="mailto:jh.hong@lge.com">Jihye Hong</a> (<span class="p-org org">LG Electronics</span>) <dd class="editor p-author h-card vcard" data-editor-id="43241"><a class="p-name fn u-url url" href="https://florian.rivoal.net">Florian Rivoal</a> (<span class="p-org org">Invited Expert</span>) <dt>Suggest an Edit for this Spec: <dd><a href="https://github.com/w3c/csswg-drafts/blob/main/css-nav-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 specification defines a general model for navigating the focus using the arrow keys, as well as related CSS, JavaScript features and Events.</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-nav” in the title, like this: “[css-nav] <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-nav%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> </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><code class="idl"><a data-link-type="idl" href="#dom-element-getspatialnavigationcontainer" id="ref-for-dom-element-getspatialnavigationcontainer">getSpatialNavigationContainer()</a></code> <li><code class="idl"><a data-link-type="idl" href="#dom-element-focusableareas" id="ref-for-dom-element-focusableareas">focusableAreas()</a></code> <li><a class="property css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain">spatial-navigation-contain</a> <li><a class="css" data-link-type="propdesc" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action">spatial-navigation-action: scroll</a> <li><a class="property css" data-link-type="property" href="#propdef-spatial-navigation-function" id="ref-for-propdef-spatial-navigation-function">spatial-navigation-function</a> </ul> <p>“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.</p> </div> <nav data-fill-with="table-of-contents" id="toc"> <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2> <ol class="toc" role="directory"> <li><a href="#intro"><span class="secno">1</span> <span class="content"> Introduction</span></a> <li> <a href="#interaction"><span class="secno">2</span> <span class="content"> Module interaction</span></a> <ol class="toc"> <li><a href="#values"><span class="secno">2.1</span> <span class="content"> CSS Property Value Definitions</span></a> </ol> <li><a href="#overview"><span class="secno">3</span> <span class="content"> Overview</span></a> <li><a href="#triggering"><span class="secno">4</span> <span class="content"> Triggering Spatial Navigation</span></a> <li> <a href="#js-api"><span class="secno">5</span> <span class="content"> JavaScript API</span></a> <ol class="toc"> <li><a href="#high-level-api"><span class="secno">5.1</span> <span class="content"> Triggering Navigation Programmatically</span></a> <li><a href="#low-level-api"><span class="secno">5.2</span> <span class="content"> Low level APIs</span></a> </ol> <li> <a href="#events-navigationevent"><span class="secno">6</span> <span class="content"> Navigation Events</span></a> <ol class="toc"> <li><a href="#interface-focusevent"><span class="secno">6.1</span> <span class="content"> Interface NavigationEvent</span></a> <li> <a href="#events-nav-type"><span class="secno">6.2</span> <span class="content"> Navigation Event Types</span></a> <ol class="toc"> <li><a href="#event-type-navbeforefocus"><span class="secno">6.2.1</span> <span class="content"> <span><code>navbeforefocus</code></span></span></a> <li><a href="#event-type-navnotarget"><span class="secno">6.2.2</span> <span class="content"> <span><code>navnotarget</code></span></span></a> </ol> </ol> <li><a href="#policy-feature"><span class="secno">7</span> <span class="content"> The <span>navigation-override</span> <span>policy-controlled feature</span></span></a> <li> <a href="#processing-model"><span class="secno">8</span> <span class="content"> Processing Model</span></a> <ol class="toc"> <li><a href="#glossary"><span class="secno">8.1</span> <span class="content"> Glossary</span></a> <li><a href="#grouping"><span class="secno">8.2</span> <span class="content"> Groupings of elements</span></a> <li><a href="#nav"><span class="secno">8.3</span> <span class="content"> Navigation</span></a> <li><a href="#heuristics"><span class="secno">8.4</span> <span class="content"> Focus Navigation Heuristics</span></a> </ol> <li> <a href="#declarative"><span class="secno">9</span> <span class="content"> Controlling spatial navigation through declarative means</span></a> <ol class="toc"> <li><a href="#container"><span class="secno">9.1</span> <span class="content"> Creating additional spatial navigation containers: the <span class="property">spatial-navigation-contain</span> property</span></a> <li><a href="#css-property-spatialnavigationaction"><span class="secno">9.2</span> <span class="content"> Controlling the interaction with scrolling: the <span class="property">spatial-navigation-action</span> property</span></a> <li><a href="#css-property-spatialnavigationfunction"><span class="secno">9.3</span> <span class="content"> Selecting the navigation algorithm: the <span class="property">spatial-navigation-function</span> property</span></a> </ol> <li><a href="#scrolling"><span class="secno"></span> <span class="content">Appendix A. Scroll extensions</span></a> <li><a href="#priv-sec"><span class="secno"></span> <span class="content"> Appendix B. Privacy and Security Considerations</span></a> <li><a href="#ack"><span class="secno"></span> <span class="content">Acknowledgements</span></a> <li><a href="#changes"><span class="secno"></span> <span class="content">Changes</span></a> <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> <li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a> </ol> <li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a> <li><a href="#idl-index"><span class="secno"></span> <span class="content">IDL Index</span></a> <li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a> </ol> </nav> <main> <p>This specification is rather long. To make it easier to read and focus on a particular area, a few checkboxes are provided below. Checking them hides part of the specification. This is only meant as a reading aid, the specification remains the full document.</p> <input id="api-check" type="checkbox"> <label for="api-check">Hide JavaScript APIs, including events</label> <br> <input id="cssapi-check" type="checkbox"> <label for="cssapi-check">Hide CSS properties that enable selecting behavior variants, and related information</label> <br> <input id="verbose-check" type="checkbox"> <label for="verbose-check">Hide informative sections that explain and summarize normative sections without adding more information</label> <br> <h2 class="non-normative 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>Historically, most browsers have not offered features to let the user move the focus directionally. Some, such as TV browsers, have enabled the user to move the focus using the arrow keys out of necessity, since no other input mechanism is available on a typical TV remote control.</p> <p>Others have enabled different key combinations to control spatial navigation, such as pressing the <code class="key">Shift</code> key together with arrow keys.</p> <p>This ability to move around the page directionally is called <dfn class="dfn-paneled" data-dfn-type="dfn" data-export data-lt="spatial navigation | spatialNavigation" id="spatial-navigation">spatial navigation</dfn>.</p> <p><a data-link-type="dfn" href="#spatial-navigation" id="ref-for-spatial-navigation">Spatial navigation</a> can be useful for a web page built using a grid-like layout, or other predominantly non linear layouts. The figure below represents a photo gallery arranged in a grid layout. If the user presses the <code class="key">Tab</code> key to move focus around the images, they need to press the key many times to reach the desired image element.</p> <figure> <img alt="When elements are laid out in a grid pattern, spatial navigation makes it much easier to predict and control where focus should move to." height="501" src="images/gallery-app.png" style="width: 500px;" width="700"> <figcaption>Photo gallery application example using a grid layout</figcaption> </figure> <p>Also, <a data-link-type="dfn" href="#spatial-navigation" id="ref-for-spatial-navigation①">spatial navigation</a> moves the focus to the predictable element for users because it moves the focus among focusable elements depending on their position. Sometimes elements on the page aren’t arranged independently of their source order. Therefore unlike <span id="ref-for-spatial-navigation②">spatial navigation</span>, sequential navigation using the <code class="key">Tab</code> key makes focus navigation unpredictable.</p> <p>While arrow keys are naturally suited to control spatial navigation, no previous specification describes how that should work, or how it may be controlled. <span class="api">This specification introduces a processing model for spatial navigation, as well as APIs enabling the author to control and override how spatial navigation works.</span></p> <p class="note" role="note"><span class="marker">Note:</span> Some aspects of this specification, such as the JavaScript Events and APIs could also be extended to sequential navigation, in order to make sure that keyboard navigation has a consistent and well defined model in general.</p> <p class="note" role="note"><span class="marker">Note:</span> As a general principle, keyboard navigation, and spatial navigation in particular, should be possible to use and control without JavaScript<span class="cssapi">, and declarative solutions are therefore preferred. Since spatial navigation depends on layout, that means CSS is typically the right mechanism to define spatial navigation related controls</span>. <span class="api">However, in the spirit of the <a href="https://github.com/extensibleweb/manifesto">Extensible Web Manifesto</a> <a data-link-type="biblio" href="#biblio-extensible" title="The Extensible Web Manifesto">[EXTENSIBLE]</a>, we feel it is important to provide the right JavaScript primitives to let the author experiment and explore the problem space. More declarative features may be added later, based on feedback and experience acquired through such JavaScript usage.</span></p> <p class="note" role="note"><span class="marker">Note:</span> A few features are marked <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="at-risk">at-risk</dfn>. The editors of this specification believe they represent an important part of the user or author experience of the features defined in the specification. At the same time, the core functionality of this specification can be implemented without implementing these so it seems possible that implementers may choose to down-prioritize them to reduce the scope of the first implementation. While it is hoped that these features will be implemented as well, they are marked at-risk in recognition that they might not be at first.</p> <h2 class="heading settled" data-level="2" id="interaction"><span class="secno">2. </span><span class="content"> Module interaction</span><a class="self-link" href="#interaction"></a></h2> <p>This document depends on the Infra Standard <a data-link-type="biblio" href="#biblio-infra" title="Infra Standard">[infra]</a>.</p> <p>The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in RFC 2119. <a data-link-type="biblio" href="#biblio-rfc2119" title="Key words for use in RFCs to Indicate Requirement Levels">[RFC2119]</a></p> <div class="cssapi"> <h3 class="heading settled" data-level="2.1" id="values"><span class="secno">2.1. </span><span class="content"> CSS Property 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> </div> <div class="verbose"> <h2 class="non-normative heading settled" data-level="3" id="overview"><span class="secno">3. </span><span class="content"> Overview</span><a class="self-link" href="#overview"></a></h2> <p><em>This section is not normative.</em></p> <p>Using a UA-defined mechanism (typically arrow keys, possibly in combination with modifier keys like <code class="key">Shift</code> or <code class="key">Control</code>), the user may ask the user agent to navigate in a particular direction. This will either move the focus from its current location to a new focusable item in the direction requested, or scroll if there is no appropriate item.</p> <p>More specifically, the user agent will first search for visible and focusable items in the direction indicated within the current <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers">spatial navigation container</a> (<span class="cssapi">by default, </span>the root element, scrollable elements, and iframes<span class="cssapi">, but other elements can be made into <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①">spatial navigation containers</a> using the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain①">spatial-navigation-contain</a> property</span>).</p> <p>If it finds any, it will pick the best one for that direction, and move the focus there.</p> <p>If it does not, it will scroll the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②">spatial navigation container</a> in the requested direction instead of moving focus. Doing so may uncover focusable elements which would then be eligible targets to move the focus to next time spatial navigation in the same direction is requested.</p> <p>If the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③">spatial navigation container</a> cannot be scrolled, either because it is not a scrollable element or because it is already scrolled to the maximum in that direction, the user agent will select the next <span id="ref-for-spatial-navigation-containers④">spatial navigation container</span> up the ancestry chain, and recursively repeat the above process until it finds some element to focus or scroll, or reaches the root element.</p> <p class="note" role="note"><span class="marker">Note:</span> As a consequence of this processing model, the elements that are reachable by sequential navigation and by spatial navigation are almost the same. Elements that are currently outside of the viewport of a scrollable element can only be reached by spatial navigation once they have been scrolled into view. Therefore, elements that cannot be scrolled into view by default.</p> <div class="api"> At key points during this search for the appropriate response to the spatial navigation request, the user agent will fire events. These enable the author to prevent the upcoming action (by calling <code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-preventdefault" id="ref-for-dom-event-preventdefault">preventDefault()</a></code>), and if desired to provide an alternate action, such as using the <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-focus" id="ref-for-dom-focus">focus()</a></code> method on a different element of the author’s choosing. <p>To help the author write such alternate actions, and as part of exposing underlying platform primitives as per the <a href="https://github.com/extensibleweb/manifesto">Extensible Web</a> principles, this specification also defines JavaScript APIs that expose key constructs of the underlying model.</p> <p>See <a href="#js-api">§ 5 JavaScript API</a> for details about the JavaScript API, <a href="#events-nav-type">§ 6.2 Navigation Event Types</a> for details about the various events, and <a href="#declarative">§ 9 Controlling spatial navigation through declarative means</a> for details about the CSS properties.</p> </div> <div class="example" id="example-f5ace946"> <a class="self-link" href="#example-f5ace946"></a> This example shows how a series of focusable elements arranged in a scrollable element would be navigated when using spatial navigation. For the sake of keeping the description simple, this example assumes a user agent where spatial navigation is triggered using arrow keys. <figure> <img alt height="474" src="images/spatnav-scroll-visible-1.png" style="width: 200px;" width="200"> <img alt height="474" src="images/spatnav-scroll-visible-2.png" style="width: 200px;" width="200"> <figcaption>Moving focus to the visible element in the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers⑤">spatial navigation container</a>.</figcaption> </figure> <p>On the left of figure 2, "Box 2" is focused. Pressing the <code class="key">ArrowDown</code> key moves the focus to "Box 3" without scrolling because "Box 3" is visible in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport">scrollport</a> of the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers⑥">spatial navigation container</a>.</p> <figure> <img alt height="473" src="images/spatnav-scroll-invisible-1.png" style="width: 160px;" width="200"> <img alt height="474" src="images/spatnav-scroll-invisible-2.png" style="width: 160px;" width="200"> <img alt height="474" src="images/spatnav-scroll-invisible-3.png" style="width: 160px;" width="200"> <img alt height="474" src="images/spatnav-scroll-invisible-4.png" style="width: 160px;" width="200"> <figcaption>Moving focus to the hidden element in the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers⑦">spatial navigation container</a>.</figcaption> </figure> <p>On the first of figure 3, under "Box 3", there isn’t any visible element in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport①">scrollport</a>. Therefore, the effect of pressing the <code class="key">ArrowDown</code> is to scroll down, as shown in the second. The next press of the <code class="key">ArrowDown</code> key makes "Box 4" come into the <span id="ref-for-scrollport②">scrollport</span>, and the focus will move to it when there is additional pressing the <code class="key">ArrowDown</code>, as the fourth.</p> <p>This example uses the markup as follows:</p> <pre class="lang-css highlight">#scroller <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>700</c-><c- k>px</c-><c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>700</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- p>}</c-> .box <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>150</c-><c- k>px</c-><c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>110</c-><c- k>px</c-><c- p>;</c-> <c- k>background-color</c-><c- p>:</c-> blue<c- p>;</c-> <c- p>}</c-> .box:focus <c- p>{</c-> <c- k>background-color</c-><c- p>:</c-> red<c- p>;</c-> <c- p>}</c-> </pre> <pre class="lang-html highlight"><c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"scroller"</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>"box"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 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>"box"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 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>"box"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 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>"box"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 4<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </pre> </div> </div> <h2 class="heading settled" data-level="4" id="triggering"><span class="secno">4. </span><span class="content"> Triggering Spatial Navigation</span><a class="self-link" href="#triggering"></a></h2> <p>When the user triggers spatial navigation in a given direction, the user agent must run the <a data-link-type="dfn" href="#spatial-navigation-steps" id="ref-for-spatial-navigation-steps">spatial navigation steps</a> in that direction.</p> <p>This specification does not define what UI mechanism user agents should offer to users to trigger spatial navigation. This intentionally left for user agents to decide.</p> <div class="note" role="note">Note: It is expected that user agents on devices with limited input capabilities, such as TVs operated with a remote control, feature phones, or devices operated with a game controller, will use spatial navigation as their primary or exclusive navigation mechanism. </div> <p>Although user agents can implement the processing model and APIs defined by the specification, this specification recommends that user agents should offer a means for users to trigger spatial navigation directly, without having to use the APIs.</p> <p class="note" role="note"><span class="marker">Note:</span> Conversely, the author should assume that spatial navigation may be triggered by the user agent in response to user actions even if the author has not invoked any of the APIs.</p> <p>Regardless of the actual mechanism chosen to trigger spatial navigation, the following requirements apply:</p> <ul> <li data-md> <p>If the mechanism the user must use to trigger spatial navigation would normally fire a <code class="idl"><a data-link-type="idl" href="https://w3c.github.io/uievents/#uievent" id="ref-for-uievent">UIEvent</a></code>, the event must be fired prior to running the <a data-link-type="dfn" href="#spatial-navigation-steps" id="ref-for-spatial-navigation-steps①">spatial navigation steps</a> and these steps must not be run if that event’s <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#canceled-flag" id="ref-for-canceled-flag">canceled flag</a> gets set.</p> <div class="example" id="example-aef71059"> <a class="self-link" href="#example-aef71059"></a> Gaming devices may trigger spatial navigation based on pressing the D-pad. This would result in firing a <a class="idl-code" data-link-type="event" href="https://w3c.github.io/uievents/#keydown" id="ref-for-keydown">keydown</a> event with the key set to one of <code class="key">ArrowDown</code>, <code class="key">ArrowLeft</code>, <code class="key">ArrowRight</code>, or <code class="key">ArrowUp</code>, followed if not canceled by running the <a data-link-type="dfn" href="#spatial-navigation-steps" id="ref-for-spatial-navigation-steps②">spatial navigation steps</a><span class="api">, including firing the relevant <code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent">NavigationEvent</a></code>s</span>. <p>A user agent on a desktop computer that triggers spatial navigation using the arrow keys of the keyboard would follow the same sequence.</p> </div> <li data-md> <p>If the mechanism the user must use to trigger spatial navigation would also perform other actions in some contexts, the user agents should in these contexts give priority to these other actions and execute them instead of spatial navigation. It must not trigger both.</p> <div class="example" id="example-01792d5c"><a class="self-link" href="#example-01792d5c"></a> In a user agent that triggers spatial navigation using the arrow keys without modifier keys, and uses these same arrow keys to move the text insertion caret when an editable element is focused, the arrow keys should by default to moving the caret. Spatial navigation would only be triggered by the arrow keys when the focused element is not editable or when it is editable, but the caret cannot move any further in the requested direction. </div> <p>An exception is made for scrolling: since spatial navigation itself handles scrolling (in addition to moving the focus) user agents should not offer the same mechanism to trigger both spatial navigation and the scrolling behavior separate from spatial navigation. However, user agents may offer a way for the user to switch between different modes, or offer both based on different UI mechanisms.</p> <div class="example" id="example-1fd6011a"><a class="self-link" href="#example-1fd6011a"></a> A user agent may have a setting to let the user choose between using the arrow keys without modifier keys for spatial navigation or for scrolling. Another one may offer scrolling on arrow keys without modifiers, and spatial navigation on arrow keys when pressed together with the <code class="key">Shift</code> key, or on the <code class="key">W</code> <code class="key">A</code> <code class="key">S</code> <code class="key">D</code> keys. Offering only spatial navigation or only scrolling as responses to pressing arrow keys would also be possibilities. </div> </ul> <div class="api"> <h2 class="heading settled" data-level="5" id="js-api"><span class="secno">5. </span><span class="content"> JavaScript API</span><a class="self-link" href="#js-api"></a></h2> <h3 class="heading settled" data-level="5.1" id="high-level-api"><span class="secno">5.1. </span><span class="content"> Triggering Navigation Programmatically</span><a class="self-link" href="#high-level-api"></a></h3> <p>The <code class="idl"><a data-link-type="idl" href="#dom-window-navigate" id="ref-for-dom-window-navigate">navigate()</a></code> method enables the author to trigger spatial navigation programmatically, as if the user had done so manually (for instance, by pressing the arrow keys in a browser where that is the way to trigger spatial navigation).</p> <p class="note" role="note"><span class="marker">Note:</span> As this triggers the same processing model as manual navigation, all the same results should be expected: the same chain of events will be fired and the same element will be scrolled or focused.</p> <p class="note" role="note"><span class="marker">Note:</span> The author can use this to trigger spatial navigation based on a different UI mechanism than the one assigned by the user agent, such as mapping to different keys, or triggering spatial navigation from a clickable on-screen directional pad, or in reaction to other events than UI ones. It could also be used when an author wants to interrupt navigation to do some asynchronous operation (e.g. load more content in an infinite scroller) then resume the navigation where they canceled.</p> <p class="note" role="note"><span class="marker">Note:</span> This API is also useful for testing purposes, as there it is difficult to trigger spatial navigation that does not depend on vendor specific UI conventions.</p> <pre class="idl highlight def"><c- b>enum</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="enum" data-export id="enumdef-spatialnavigationdirection"><code><c- g>SpatialNavigationDirection</c-></code></dfn> { <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationDirection" data-dfn-type="enum-value" data-export id="dom-spatialnavigationdirection-up"><code><c- s>"up"</c-></code></dfn>, <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationDirection" data-dfn-type="enum-value" data-export id="dom-spatialnavigationdirection-down"><code><c- s>"down"</c-></code></dfn>, <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationDirection" data-dfn-type="enum-value" data-export id="dom-spatialnavigationdirection-left"><code><c- s>"left"</c-></code></dfn>, <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationDirection" data-dfn-type="enum-value" data-export id="dom-spatialnavigationdirection-right"><code><c- s>"right"</c-></code></dfn>, }; <c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#window" id="ref-for-window"><c- g>Window</c-></a> { <a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-undefined" id="ref-for-idl-undefined"><c- b>undefined</c-></a> <a class="idl-code" data-link-type="method" href="#dom-window-navigate" id="ref-for-dom-window-navigate①"><c- g>navigate</c-></a>(<a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection" id="ref-for-enumdef-spatialnavigationdirection"><c- n>SpatialNavigationDirection</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="Window/navigate(dir)" data-dfn-type="argument" data-export id="dom-window-navigate-dir-dir"><code><c- g>dir</c-></code></dfn>); }; </pre> <div class="algorithm" data-algorithm="windowNavigate steps"> When the <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="method" data-export id="dom-window-navigate"><code>navigate(dir)</code></dfn> method is called, the user agent must run the following step: <ul> <li data-md> <p>If direction <var>dir</var> is <code>"up"</code>, <code>"down"</code>, <code>"left"</code>, or <code>"right"</code>, run the <a data-link-type="dfn" href="#spatial-navigation-steps" id="ref-for-spatial-navigation-steps③">spatial navigation steps</a> in <var>dir</var>.</p> </ul> <p class="issue" id="issue-a5a227c8"><a class="self-link" href="#issue-a5a227c8"></a> The name of this API is under discussion <a href="https://github.com/w3c/csswg-drafts/issues/3387">[Issue #3387]</a></p> </div> <h3 class="heading settled" data-level="5.2" id="low-level-api"><span class="secno">5.2. </span><span class="content"> Low level APIs</span><a class="self-link" href="#low-level-api"></a></h3> <p>These APIs are designed to be low level constructs following the processing model closely. As such, they should be easy to use by the author who wants to extend or override the way spatial navigation works.</p> <pre class="idl highlight def"><c- b>enum</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="enum" data-export id="enumdef-focusableareasearchmode"><code><c- g>FocusableAreaSearchMode</c-></code></dfn> { <dfn class="dfn-paneled idl-code" data-dfn-for="FocusableAreaSearchMode" data-dfn-type="enum-value" data-export id="dom-focusableareasearchmode-visible"><code><c- s>"visible"</c-></code></dfn>, <dfn class="dfn-paneled idl-code" data-dfn-for="FocusableAreaSearchMode" data-dfn-type="enum-value" data-export id="dom-focusableareasearchmode-all"><code><c- s>"all"</c-></code></dfn> }; <c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-focusableareasoption"><code><c- g>FocusableAreasOption</c-></code></dfn> { <a data-link-type="idl-name" href="#enumdef-focusableareasearchmode" id="ref-for-enumdef-focusableareasearchmode"><c- n>FocusableAreaSearchMode</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="FocusableAreasOption" data-dfn-type="dict-member" data-export data-type="FocusableAreaSearchMode" id="dom-focusableareasoption-mode"><code><c- g>mode</c-></code></dfn>; }; <c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-spatialnavigationsearchoptions"><code><c- g>SpatialNavigationSearchOptions</c-></code></dfn> { <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence" id="ref-for-idl-sequence"><c- b>sequence</c-></a><<a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node" id="ref-for-node"><c- n>Node</c-></a>>? <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationSearchOptions" data-dfn-type="dict-member" data-export data-type="sequence<Node>?" id="dom-spatialnavigationsearchoptions-candidates"><code><c- g>candidates</c-></code></dfn>; <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node" id="ref-for-node①"><c- n>Node</c-></a>? <dfn class="dfn-paneled idl-code" data-dfn-for="SpatialNavigationSearchOptions" data-dfn-type="dict-member" data-export data-type="Node?" id="dom-spatialnavigationsearchoptions-container"><code><c- g>container</c-></code></dfn>; }; <c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#element" id="ref-for-element"><c- g>Element</c-></a> { <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node" id="ref-for-node②"><c- n>Node</c-></a> <a class="idl-code" data-link-type="method" href="#dom-element-getspatialnavigationcontainer" id="ref-for-dom-element-getspatialnavigationcontainer①"><c- g>getSpatialNavigationContainer</c-></a>(); <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence" id="ref-for-idl-sequence①"><c- b>sequence</c-></a><<a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node" id="ref-for-node③"><c- n>Node</c-></a>> <a class="idl-code" data-link-type="method" href="#dom-element-focusableareas" id="ref-for-dom-element-focusableareas①"><c- g>focusableAreas</c-></a>(<c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-focusableareasoption" id="ref-for-dictdef-focusableareasoption"><c- n>FocusableAreasOption</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="Element/focusableAreas(option), Element/focusableAreas()" data-dfn-type="argument" data-export id="dom-element-focusableareas-option-option"><code><c- g>option</c-></code></dfn> = {}); <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node" id="ref-for-node④"><c- n>Node</c-></a>? <dfn class="dfn-paneled idl-code" data-dfn-for="Element" data-dfn-type="method" data-export data-lt="spatialNavigationSearch(dir, options)|spatialNavigationSearch(dir)" id="dom-element-spatialnavigationsearch"><code><c- g>spatialNavigationSearch</c-></code></dfn>(<a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection" id="ref-for-enumdef-spatialnavigationdirection①"><c- n>SpatialNavigationDirection</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="Element/spatialNavigationSearch(dir, options), Element/spatialNavigationSearch(dir)" data-dfn-type="argument" data-export id="dom-element-spatialnavigationsearch-dir-options-dir"><code><c- g>dir</c-></code></dfn>, <c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-spatialnavigationsearchoptions" id="ref-for-dictdef-spatialnavigationsearchoptions"><c- n>SpatialNavigationSearchOptions</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="Element/spatialNavigationSearch(dir, options), Element/spatialNavigationSearch(dir)" data-dfn-type="argument" data-export id="dom-element-spatialnavigationsearch-dir-options-options"><code><c- g>options</c-></code></dfn> = {}); }; </pre> <p class="note" role="note"><span class="marker">Note:</span> The way the direction is expressed allows us to expand to more than 4-way navigation later if this is found necessary. More directional keywords or a numerical angle could be added.</p> <p class="note" role="note"><span class="marker">Note:</span> the <code class="idl"><a data-link-type="idl" href="#dom-element-focusableareas" id="ref-for-dom-element-focusableareas②">focusableAreas()</a></code> and <code class="idl"><a data-link-type="idl" href="#dom-element-getspatialnavigationcontainer" id="ref-for-dom-element-getspatialnavigationcontainer②">getSpatialNavigationContainer()</a></code> methods are <a data-link-type="dfn" href="#at-risk" id="ref-for-at-risk">at-risk</a>.</p> <p>When these methods are called, the user agent must run the steps described below:</p> <div class="algorithm" data-algorithm="getSpatialNavigationContainer steps"> <dl> <dt data-md><dfn class="dfn-paneled idl-code" data-dfn-for="Element" data-dfn-type="method" data-export id="dom-element-getspatialnavigationcontainer"><code>getSpatialNavigationContainer()</code></dfn> <dd data-md> <ol> <li data-md> <p>Return the nearest ancestor of the element that is a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers⑧">spatial navigation container</a>, or the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#clone-a-node-document" id="ref-for-clone-a-node-document">document</a> if the nearest <span id="ref-for-spatial-navigation-containers⑨">spatial navigation container</span> is the viewport.</p> </ol> <p class="note" role="note"><span class="marker">Note:</span> If the element is a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①⓪">spatial navigation container</a>, <code class="idl"><a data-link-type="idl" href="#dom-element-getspatialnavigationcontainer" id="ref-for-dom-element-getspatialnavigationcontainer③">getSpatialNavigationContainer()</a></code> also returns the nearest <span id="ref-for-spatial-navigation-containers①①">spatial navigation container</span>, not the element itself.</p> </dl> </div> <div class="algorithm" data-algorithm="focusableAreas steps"> <dl> <dt data-md><dfn class="dfn-paneled idl-code" data-dfn-for="Element" data-dfn-type="method" data-export data-lt="focusableAreas(option)|focusableAreas()" id="dom-element-focusableareas"><code>focusableAreas(<var>option</var>)</code></dfn> <dd data-md> <ol> <li data-md> <p>Let <var>visibleOnly</var> be <code>false</code> if <var>option</var> is present and its value is equal to <code><a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-cascade-5/#propdef-all" id="ref-for-propdef-all">all</a></code>, or <code>true</code> otherwise.</p> <li data-md> <p>Let <var>areas</var> be the result of <a data-link-type="dfn" href="#find-focusable-areas" id="ref-for-find-focusable-areas">finding focusable areas</a> within the element with <var>visibleOnly</var> as argument.</p> <li data-md> <p>Return <var>areas</var></p> </ol> </dl> </div> <div class="example" id="focusAreas-visible"> <a class="self-link" href="#focusAreas-visible"></a> The following code shows how to get all the visible focusable elements in the current page using <code class="idl"><a data-link-type="idl" href="#dom-element-focusableareas" id="ref-for-dom-element-focusableareas③">focusableAreas()</a></code>. If the method finds a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①②">spatial navigation container</a>, it recursively finds focusable areas inside it. Because the value of the <code class="idl"><a data-link-type="idl" href="#dom-focusableareasoption-mode" id="ref-for-dom-focusableareasoption-mode">mode</a></code> attribute in this method is <code>visible</code>, the focusable elements which aren’t inside the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport③">scrollport</a> are excluded from the result. <pre><code class="highlight"><c- p><</c-><c- f>body</c-><c- p>></c-> <c- p><</c-><c- f>button</c-><c- p>></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>style</c-><c- o>=</c-><c- s>"width:300px; height:200px; overflow-x: scroll;"</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>style</c-><c- o>=</c-><c- s>"left:25px;"</c-><c- p>></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>style</c-><c- o>=</c-><c- s>"left:150px;"</c-><c- p>></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>style</c-><c- o>=</c-><c- s>"left:350px;"</c-><c- p>></</c-><c- f>button</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> <c- p></</c-><c- f>body</c-><c- p>></c-> </code></pre> <pre><code class="highlight"><c- a>const</c-> focusableAreas <c- o>=</c-> document<c- p>.</c->body<c- p>.</c->focusableAreas<c- p>({</c->mode<c- o>:</c-> <c- t>'visible'</c-><c- p>});</c-> focusableAreas <c- o>&&</c-> focusableAreas<c- p>.</c->forEach<c- p>(</c->focusable <c- p>=></c-> <c- p>{</c-> focusable<c- p>.</c->style<c- p>.</c->outline <c- o>=</c-> <c- t>'5px solid red'</c-><c- p>;</c-> <c- p>});</c-> </code></pre> <p>The figure below is the result of this code.</p> <figure> <img alt="An image about focusableAreas()" height="230" src="images/focusableareas-visible-example.png" style="width: 450px;" width="500"> <figcaption>Find all visible focusable areas inside the document.</figcaption> </figure> </div> <div class="algorithm" data-algorithm="spatialNavigationSearch steps"> <dl> <dt data-md><dfn class="dfn-paneled idl-code" data-dfn-for="Element" data-dfn-type="method" data-export data-lt="spatialNavigationSearch(options)" id="dom-element-spatialnavigationsearch-options"><code>spatialNavigationSearch(<var>dir</var>, <var>options</var>)</code></dfn> <dd data-md> <ol> <li data-md> <p>Let <var>direction</var> be the value of <var>dir</var>.</p> <li data-md> <p>Let <var>container</var> be</p> <ul> <li data-md> <p>if the value of <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationsearchoptions-container" id="ref-for-dom-spatialnavigationsearchoptions-container">container</a></code> attribute of <var>options</var> is not null,</p> <ul> <li data-md> <p>itself, if it is <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①③">spatial navigation container</a>.</p> <li data-md> <p>its nearest <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①④">spatial navigation container</a> ancestor, otherwise.</p> </ul> <li data-md> <p>else the element’s nearest <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①⑤">spatial navigation container</a> ancestor.</p> </ul> <li data-md> <p>Let <var>areas</var> be</p> <ul> <li data-md> <p>the value of <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationsearchoptions-candidates" id="ref-for-dom-spatialnavigationsearchoptions-candidates">candidates</a></code> attribute of <var>options</var> if it is not <code>null</code>,</p> <li data-md> <p>result of <a data-link-type="dfn" href="#find-focusable-areas" id="ref-for-find-focusable-areas①">finding focusable areas</a> within <var>container</var> otherwise.</p> </ul> <li data-md> <p>Return the result of <a data-link-type="dfn" href="#select-the-best-candidate" id="ref-for-select-the-best-candidate">selecting the best candidate</a> among <var>areas</var> within <var>container</var> in <var>direction</var> from the element.</p> </ol> </dl> <p class="note" role="note"><span class="marker">Note:</span> When neither a container nor a list of candidates is provided, this only searches through the visible focusable areas of the nearest <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①⑥">spatial navigation container</a> ancestor. <em>If there isn’t any, this does not climb further up the ancestry chain, and the result will be <code>null</code>.</em></p> </div> </div> <div class="api"> <h2 class="heading settled" data-level="6" id="events-navigationevent"><span class="secno">6. </span><span class="content"> Navigation Events</span><a class="self-link" href="#events-navigationevent"></a></h2> <h3 class="heading settled" data-level="6.1" id="interface-focusevent"><span class="secno">6.1. </span><span class="content"> Interface NavigationEvent</span><a class="self-link" href="#interface-focusevent"></a></h3> <p>The <code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent①">NavigationEvent</a></code> interface provides specific contextual information associated with spatial navigation.</p> <p>To create an instance of the <code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent②">NavigationEvent</a></code> interface, use the <code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent③">NavigationEvent</a></code> constructor, passing an optional <code class="idl"><a data-link-type="idl" href="#dictdef-navigationeventinit" id="ref-for-dictdef-navigationeventinit">NavigationEventInit</a></code> dictionary.</p> <pre class="idl highlight def">[<a class="idl-code" data-link-type="extended-attribute" href="https://webidl.spec.whatwg.org/#Exposed" id="ref-for-Exposed"><c- g>Exposed</c-></a>=<c- n>Window</c->] <c- b>interface</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export id="navigationevent"><code><c- g>NavigationEvent</c-></code></dfn> : <a data-link-type="idl-name" href="https://w3c.github.io/uievents/#uievent" id="ref-for-uievent①"><c- n>UIEvent</c-></a> { <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent" data-dfn-type="constructor" data-export data-lt="NavigationEvent(type, eventInitDict)|constructor(type, eventInitDict)|NavigationEvent(type)|constructor(type)" id="dom-navigationevent-navigationevent"><code><c- g>constructor</c-></code></dfn>(<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-DOMString" id="ref-for-idl-DOMString"><c- b>DOMString</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent/NavigationEvent(type, eventInitDict), NavigationEvent/constructor(type, eventInitDict), NavigationEvent/NavigationEvent(type), NavigationEvent/constructor(type)" data-dfn-type="argument" data-export id="dom-navigationevent-navigationevent-type-eventinitdict-type"><code><c- g>type</c-></code></dfn>, <c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-navigationeventinit" id="ref-for-dictdef-navigationeventinit①"><c- n>NavigationEventInit</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent/NavigationEvent(type, eventInitDict), NavigationEvent/constructor(type, eventInitDict), NavigationEvent/NavigationEvent(type), NavigationEvent/constructor(type)" data-dfn-type="argument" data-export id="dom-navigationevent-navigationevent-type-eventinitdict-eventinitdict"><code><c- g>eventInitDict</c-></code></dfn> = {}); <c- b>readonly</c-> <c- b>attribute</c-> <a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection" id="ref-for-enumdef-spatialnavigationdirection②"><c- n>SpatialNavigationDirection</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent" data-dfn-type="attribute" data-export data-readonly data-type="SpatialNavigationDirection" id="dom-navigationevent-dir"><code><c- g>dir</c-></code></dfn>; <c- b>readonly</c-> <c- b>attribute</c-> <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget" id="ref-for-eventtarget"><c- n>EventTarget</c-></a>? <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent" data-dfn-type="attribute" data-export data-readonly data-type="EventTarget?" id="dom-navigationevent-relatedtarget"><code><c- g>relatedTarget</c-></code></dfn>; }; <c- b>dictionary</c-> <dfn class="dfn-paneled idl-code" data-dfn-type="dictionary" data-export id="dictdef-navigationeventinit"><code><c- g>NavigationEventInit</c-></code></dfn> : <a data-link-type="idl-name" href="https://w3c.github.io/uievents/#dictdef-uieventinit" id="ref-for-dictdef-uieventinit"><c- n>UIEventInit</c-></a> { <a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection" id="ref-for-enumdef-spatialnavigationdirection③"><c- n>SpatialNavigationDirection</c-></a> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEventInit" data-dfn-type="dict-member" data-export data-type="SpatialNavigationDirection" id="dom-navigationeventinit-dir"><code><c- g>dir</c-></code></dfn>; <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget" id="ref-for-eventtarget①"><c- n>EventTarget</c-></a>? <dfn class="dfn-paneled idl-code" data-default="null" data-dfn-for="NavigationEventInit" data-dfn-type="dict-member" data-export data-type="EventTarget?" id="dom-navigationeventinit-relatedtarget"><code><c- g>relatedTarget</c-></code></dfn> = <c- b>null</c->; }; </pre> <div class="verbose"> <h3 class="non-normative heading settled" data-level="6.2" id="events-nav-type"><span class="secno">6.2. </span><span class="content"> Navigation Event Types</span><a class="self-link" href="#events-nav-type"></a></h3> <p><em>This section and its subsections are not normative.</em></p> <p>The Navigation event types are summarized below. For full normative details, see <a href="#processing-model">§ 8 Processing Model</a>.</p> <h4 class="non-normative heading settled" data-level="6.2.1" id="event-type-navbeforefocus"><span class="secno">6.2.1. </span><span class="content"> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent" data-dfn-type="event" data-export id="eventdef-navigationevent-navbeforefocus"><code>navbeforefocus</code></dfn></span><a class="self-link" href="#event-type-navbeforefocus"></a></h4> <p>This event occurs when there is a valid result of <a data-link-type="dfn" href="#select-the-best-candidate" id="ref-for-select-the-best-candidate①">selecting the best candidate</a>.</p> <table class="def"> <tbody> <tr> <th>Type <td><strong><code>navbeforefocus</code></strong> <tr> <th>Interface <td><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent④">NavigationEvent</a></code> <tr> <th>Bubbles <td>Yes <tr> <th>Cancelable <td>Yes <tr> <th>Attributes of the event <td> <dl> <dt><code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#event" id="ref-for-event">Event</a></code>.<code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-target" id="ref-for-dom-event-target">target</a></code> <dd>The focused element or if no element focused, then <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2" id="ref-for-the-body-element-2">the body element</a> if available, otherwise the root element <dt><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent⑤">NavigationEvent</a></code>.<code class="idl"><a data-link-type="idl" href="#dom-navigationevent-relatedtarget" id="ref-for-dom-navigationevent-relatedtarget">relatedTarget</a></code> <dd>The DOM anchor of the focusable area that will be focused <dt><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent⑥">NavigationEvent</a></code>.<code class="idl"><a data-link-type="idl" href="#dom-navigationevent-dir" id="ref-for-dom-navigationevent-dir">dir</a></code> <dd>The direction of the navigation as requested by the user </dl> </table> <p>The user agent <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="dispatches navbeforefocus event | dispatching navbeforefocus event" data-noexport id="dispatches-navbeforefocus-event">dispatches <a class="idl-code" data-link-type="event" href="#eventdef-navigationevent-navbeforefocus" id="ref-for-eventdef-navigationevent-navbeforefocus">navbeforefocus</a> event</dfn> before spatial navigation moves the focus. The <a data-link-type="dfn" href="https://w3c.github.io/uievents/#event-target" id="ref-for-event-target">event target</a> is the element which has focus and the <code class="idl"><a data-link-type="idl" href="#dom-navigationevent-relatedtarget" id="ref-for-dom-navigationevent-relatedtarget①">relatedTarget</a></code> is the element which is about to receive focus.</p> <p>If <a data-link-type="dfn" href="#navigation-override" id="ref-for-navigation-override">navigation-override</a> is disabled in the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-node-document" id="ref-for-concept-node-document">node document</a> of <var>eventTarget</var> for the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin" id="ref-for-concept-origin">origin</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document" id="ref-for-nav-document">active document</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context" id="ref-for-top-level-browsing-context">top-level browsing context</a>, this event won’t be dispatched.</p> <div class="example" id="example-f9b67f46"> <a class="self-link" href="#example-f9b67f46"></a> This example shows the <a data-link-type="dfn">event order</a> when pressing the <code class="key">ArrowRight</code> key. For the sake of keeping the description simple, this example assumes a user agent where spatial navigation is triggered using arrow keys. <table class="complex data"> <thead> <tr> <th> <th>Event type <th><code class="idl"><a data-link-type="idl" href="https://w3c.github.io/uievents/#keyboardevent" id="ref-for-keyboardevent">KeyboardEvent</a></code>.<code class="idl"><a data-link-type="idl" href="https://w3c.github.io/uievents/#dom-keyboardevent-key" id="ref-for-dom-keyboardevent-key">key</a></code> <th>Notes <tbody> <tr> <td>1 <td>keydown <td><code class="key">ArrowRight</code> <td>MUST be a key which can activate spatial navigation, such as the arrow keys, or spatial navigation is not activated. <tr> <td>2 <td>navbeforefocus <td> <td>Sent if the candidates for spatial navigation is not <code>null</code>, or this is not generated. <tr> <td>3 <td>focusin <td> <td>Sent before the target element receives focus. <tr> <td>4 <td>focus <td> <td>Sent after the target element receives focus. </table> </div> <div class="example" id="delegation"> <a class="self-link" href="#delegation"></a> The following code changes the behavior of spatial navigation so that when a scroll container would get focused, if it has at least one visible focusable descendant, the focus is automatically transferred to it, recursively. <pre><code class="highlight">document<c- p>.</c->addEventListener<c- p>(</c-><c- t>'navbeforefocus'</c-><c- p>,</c-> e <c- p>=></c-> <c- p>{</c-> e<c- p>.</c->preventDefault<c- p>();</c-> <c- a>let</c-> nextTarget <c- o>=</c-> e<c- p>.</c->relatedTarget<c- p>;</c-> <c- k>if</c-> <c- p>(</c->isSpatialNavigationContainer<c- p>(</c->nextTarget<c- p>))</c-> <c- p>{</c-> <c- a>const</c-> areas <c- o>=</c-> nextTarget<c- p>.</c->focusableAreas<c- p>();</c-> <c- k>if</c-> <c- p>(</c->areas<c- p>.</c->length <c- o>></c-> <c- mf>0</c-><c- p>)</c-> <c- p>{</c-> nextTarget <c- o>=</c-> nextTarget<c- p>.</c->spatialNavigationSearch<c- p>(</c->e<c- p>.</c->dir<c- p>,</c-> <c- p>{</c-> candidates<c- o>:</c-> areas <c- p>});</c-> <c- p>}</c-> <c- p>}</c-> nextTarget<c- p>.</c->focus<c- p>();</c-> <c- p>});</c-> <c- a>function</c-> isSpatialNavigationContainer<c- p>(</c->element<c- p>)</c-> <c- p>{</c-> <c- k>return</c-> <c- p>(</c-><c- o>!</c->element<c- p>.</c->parentElement<c- p>)</c-> <c- o>||</c-> <c- p>(</c->element<c- p>.</c->nodeName <c- o>===</c-> <c- t>'IFRAME'</c-><c- p>)</c-> <c- o>||</c-> <c- p>(</c->isScrollContainer<c- p>(</c->element<c- p>))</c-> <c- o>||</c-> <c- p>(</c->isCSSSpatNavContain<c- p>(</c->element<c- p>));</c-> <c- p>}</c-> </code></pre> </div> <h4 class="non-normative heading settled" data-level="6.2.2" id="event-type-navnotarget"><span class="secno">6.2.2. </span><span class="content"> <dfn class="dfn-paneled idl-code" data-dfn-for="NavigationEvent" data-dfn-type="event" data-export id="eventdef-navigationevent-navnotarget"><code>navnotarget</code></dfn></span><a class="self-link" href="#event-type-navnotarget"></a></h4> <p>This event occurs before going up the tree to search candidates in the nearest ancestor <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers①⑦">spatial navigation container</a> when spatial navigation has failed to find any candidate within the current <span id="ref-for-spatial-navigation-containers①⑧">spatial navigation container</span>, and in cases where the <span id="ref-for-spatial-navigation-containers①⑨">spatial navigation container</span> is scrollable, when it cannot be scrolled further.</p> <table class="def"> <tbody> <tr> <th>Type <td><strong><code>navnotarget</code></strong> <tr> <th>Interface <td><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent⑦">NavigationEvent</a></code> <tr> <th>Bubbles <td>Yes <tr> <th>Cancelable <td>Yes <tr> <th>Attributes of the event <td> <dl> <dt><code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#event" id="ref-for-event①">Event</a></code>.<code class="idl"><a data-link-type="idl" href="https://dom.spec.whatwg.org/#dom-event-target" id="ref-for-dom-event-target①">target</a></code> <dd>The focused element or if no element focused, then <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2" id="ref-for-the-body-element-2①">the body element</a> if available, otherwise the root element <dt><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent⑧">NavigationEvent</a></code>.<code class="idl"><a data-link-type="idl" href="#dom-navigationevent-relatedtarget" id="ref-for-dom-navigationevent-relatedtarget②">relatedTarget</a></code> <dd>The <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⓪">spatial navigation container</a> that was searched in. <dt><code class="idl"><a data-link-type="idl" href="#navigationevent" id="ref-for-navigationevent⑨">NavigationEvent</a></code>.<code class="idl"><a data-link-type="idl" href="#dom-navigationevent-dir" id="ref-for-dom-navigationevent-dir①">dir</a></code> <dd>The direction of the navigation as requested by the user </dl> </table> <p>The user agent <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="dispatches navnotarget event | dispatching navnotarget event" data-noexport id="dispatches-navnotarget-event">dispatches <a class="idl-code" data-link-type="event" href="#eventdef-navigationevent-navnotarget" id="ref-for-eventdef-navigationevent-navnotarget">navnotarget</a> event</dfn> with initializing the <a data-link-type="dfn" href="https://w3c.github.io/uievents/#event-target" id="ref-for-event-target①">event target</a> as the element which has focus and the <code class="idl"><a data-link-type="idl" href="#dom-navigationevent-relatedtarget" id="ref-for-dom-navigationevent-relatedtarget③">relatedTarget</a></code> as <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②①">spatial navigation container</a> of the <span id="ref-for-event-target②">event target</span>.</p> <p>If <a data-link-type="dfn" href="#navigation-override" id="ref-for-navigation-override①">navigation-override</a> is disabled in the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#concept-node-document" id="ref-for-concept-node-document①">node document</a> of <var>eventTarget</var> for the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#concept-origin" id="ref-for-concept-origin①">origin</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document" id="ref-for-nav-document①">active document</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context" id="ref-for-top-level-browsing-context①">top-level browsing context</a>, this event won’t be dispatched.</p> <div class="example" id="example-7982a275"> <a class="self-link" href="#example-7982a275"></a> This example shows the <a data-link-type="dfn">event order</a> when pressing the <code class="key">ArrowDown</code> key in the situation like the following figure. For the sake of keeping the description simple, this example assumes a user agent where spatial navigation is triggered using arrow keys. <figure> <img alt="An image about navnotarget" height="326" src="images/navnotarget-example-1.png" style="width: 200px;" width="200"> <figcaption>Moving focus when there isn’t any candidate in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container">scroll container</a>.</figcaption> </figure> <table class="complex data"> <thead> <tr> <th> <th>Event type <th>Event target <th><code>relatedTarget</code> <th>Notes <tbody> <tr> <td>1 <td>keydown <td><code>#box2</code> <td>N/A <td>MUST be a key which can activate spatial navigation, such as the arrow keys, otherwise spatial navigation is not triggered. <tr> <td>2 <td>navnotarget <td><code>#box2</code> <td><code>#scrollContainer</code> <td>Sent if <code>#scrollContainer</code> doesn’t contain any candidate and cannot be scrolled, otherwise this would not be generated. <tr> <td>3 <td>navbeforefocus <td><code>#box2</code> <td><code>#box3</code> <td>Sent if the candidates in <code>#container</code> is not <code>null</code>, otherwise this would not be fired. <tr> <td>4 <td>focusin <td><code>#box3</code> <td><code>#box2</code> <td>Sent before the target element receives focus. <tr> <td>5 <td>focus <td><code>#box3</code> <td><code>#box2</code> <td>Sent after the target element receives focus. </table> <p>The result of this example is the figure as follows:</p> <figure> <img alt="An image of the result about navnotarget" height="326" src="images/navnotarget-example-2.png" style="width: 200px;" width="200"> <figcaption>The result of moving focus when there isn’t any candidate in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport④">scrollport</a> and <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 scrolled.</figcaption> </figure> <p>This example uses the markup as follows:</p> <pre class="lang-css highlight">#container <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>900</c-><c- k>px</c-><c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>1400</c-><c- k>px</c-><c- p>;</c-> <c- p>}</c-> #scrollContainer <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>700</c-><c- k>px</c-><c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>700</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- p>}</c-> .item <c- p>{</c-> <c- k>width</c-><c- p>:</c-> <c- m>150</c-><c- k>px</c-><c- p>;</c-> <c- k>height</c-><c- p>:</c-> <c- m>110</c-><c- k>px</c-><c- p>;</c-> <c- k>background-color</c-><c- p>:</c-> blue<c- p>;</c-> <c- p>}</c-> .item:focus <c- p>{</c-> <c- k>background-color</c-><c- p>:</c-> red<c- p>;</c-> <c- p>}</c-> </pre> <pre class="lang-html highlight"><c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"container"</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"scrollContainer"</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"box1"</c-> <c- e>class</c-><c- o>=</c-><c- s>"item"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 1<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"box2"</c-> <c- e>class</c-><c- o>=</c-><c- s>"item"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 2<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>"box3"</c-> <c- e>class</c-><c- o>=</c-><c- s>"item"</c-> <c- e>tabindex</c-><c- o>=</c-><c- s>"0"</c-><c- p>></c->Box 3<c- p></</c-><c- f>div</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </pre> </div> <div class="example" id="loop"> <a class="self-link" href="#loop"></a> The following code changes the behavior of spatial navigation to trap the focus within a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②②">spatial navigation container</a> which is vertically scrollable. When no further focusable elements can be found in the requested direction and the <span id="ref-for-spatial-navigation-containers②③">spatial navigation container</span> cannot be scrolled any further, the focus loops back to the other side instead of moving outside of it. <p>However, the focus can still be moved outside by sequential navigation, mouse interaction, or programmatic calls to <code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-focus" id="ref-for-dom-focus①">focus()</a></code>.</p> <pre><code class="highlight">scrollContainer<c- p>.</c->addEventListener<c- p>(</c-><c- t>'navnotarget'</c-><c- p>,</c-> e <c- p>=></c-> <c- p>{</c-> <c- a>let</c-> nextTarget <c- o>=</c-> <c- kc>null</c-><c- p>;</c-> <c- a>const</c-> verticalDir <c- o>=</c-> <c- p>[</c-><c- t>'up'</c-><c- p>,</c-> <c- t>'down'</c-><c- p>];</c-> <c- a>const</c-> candidates <c- o>=</c-> e<c- p>.</c->relatedTarget<c- p>.</c->focusableAreas<c- p>({</c-><c- t>'mode'</c-><c- o>:</c-> <c- t>'all'</c-><c- p>});</c-> <c- c1>// Prevent default only when navigation direction is on y-axis</c-> <c- k>if</c-> <c- p>(</c->verticalDir<c- p>.</c->includes<c- p>(</c->e<c- p>.</c->dir<c- p>)</c-> <c- o>&&</c-> <c- p>(</c->candidates<c- p>.</c->length <c- o>></c-> <c- mf>0</c-><c- p>))</c-> <c- p>{</c-> e<c- p>.</c->preventDefault<c- p>();</c-> <c- k>if</c-> <c- p>(</c->e<c- p>.</c->dir <c- o>===</c-> <c- t>'down'</c-><c- p>)</c-> <c- p>{</c-> nextTarget <c- o>=</c-> candidates<c- p>[</c-><c- mf>0</c-><c- p>];</c-> <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->e<c- p>.</c->dir <c- o>===</c-> <c- t>'up'</c-><c- p>)</c-> <c- p>{</c-> nextTarget <c- o>=</c-> candidates<c- p>[</c->candidates<c- p>.</c->length<c- o>-</c-><c- mf>1</c-><c- p>];</c-> <c- p>}</c-> nextTarget<c- p>.</c->focus<c- p>();</c-> <c- p>}</c-> <c- p>});</c-> </code></pre> </div> </div> </div> <h2 class="heading settled" data-level="7" id="policy-feature"><span class="secno">7. </span><span class="content"> The <a data-link-type="dfn" href="#navigation-override" id="ref-for-navigation-override②">navigation-override</a> <a data-link-type="dfn" href="https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature" id="ref-for-policy-controlled-feature">policy-controlled feature</a></span><a class="self-link" href="#policy-feature"></a></h2> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="navigation-override">navigation-override</dfn> <a data-link-type="dfn" href="https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature" id="ref-for-policy-controlled-feature①">policy-controlled feature</a> controls the availability of mechanisms that enables the page author to take control over the behavior of spatial navigation, or to cancel it outright.</p> <ul> <li data-md> <p>The feature name is "<code>navigation-override</code>"</p> <li data-md> <p>The <a data-link-type="dfn" href="https://w3c.github.io/webappsec-feature-policy/#default-allowlist" id="ref-for-default-allowlist">default allowlist</a> for <a data-link-type="dfn" href="#navigation-override" id="ref-for-navigation-override③">navigation-override</a> is "<code>self</code>"</p> </ul> <p>As defined in further details in <a href="#nav">§ 8.3 Navigation</a>, if <a data-link-type="dfn" href="#navigation-override" id="ref-for-navigation-override④">navigation-override</a> is disabled in a document, the navigation events (see <a href="#events-navigationevent">§ 6 Navigation Events</a>) will not be fired.</p> <p class="note" role="note"><span class="marker">Note:</span> This is to prevent a hostile iframe from using these events in order to hijack the focus. We recognize that there exist other mechanisms predating spatial navigation that malicious the author could use to interfere with the user’s ability to control where the focus goes. Despite that, it seems worthwhile to attempt not to increase this attack surface, although it is possible that such attacks are already sufficiently easy to perform that this is a lost cause. Further feedback on this topic, based on experience with implementation or with mitigating such attacks, is very welcome.</p> <h2 class="heading settled" data-level="8" id="processing-model"><span class="secno">8. </span><span class="content"> Processing Model</span><a class="self-link" href="#processing-model"></a></h2> <div class="verbose"> The <a href="#overview">§ 3 Overview</a> section gives a high level idea of how spatial navigation works, to help readers of this specification build a general mental model. It uses intuitive but imprecise terminology, and glosses over many details for the sake of readability. <p>This section defines the corresponding normative behavior and aims for as much detail as necessary to fully define the behavior.</p> </div> <h3 class="heading settled" data-level="8.1" id="glossary"><span class="secno">8.1. </span><span class="content"> Glossary</span><a class="self-link" href="#glossary"></a></h3> <p>The following term definitions have been specified to explain the processing model for spatial navigation. See the links within the definitions for more information.</p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="boundary-box">boundary box</dfn> of an object is defined as follows:</p> <ul> <li data-md> <p>if the object is a point, the boundary box is that point</p> <li data-md> <p>if the object is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#box" id="ref-for-box">box</a> or <a data-link-type="dfn" href="https://drafts.csswg.org/css-break-4/#box-fragment" id="ref-for-box-fragment">box fragment</a>, the boundary box is the <a data-link-type="dfn" href="https://drafts.csswg.org/css2/box.html#x14" id="ref-for-x14">border box</a> of that box or fragment</p> <li data-md> <p>if the object is a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area" id="ref-for-focusable-area">focusable area</a> which is not an element, the boundary box is the axis-aligned the bounding box of that <span id="ref-for-focusable-area①">focusable area</span></p> </ul> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="inside-area">inside area</dfn> of an object is defined as follows:</p> <ul> <li data-md> <p>if the object 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>, its <a data-link-type="dfn" href="https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region" id="ref-for-optimal-viewing-region">optimal viewing region</a></p> <li data-md> <p>if the object is a <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#clone-a-node-document" id="ref-for-clone-a-node-document①">document</a>, the viewport of its <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context" id="ref-for-browsing-context">browsing context</a></p> <li data-md> <p>if the object is a <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#box" id="ref-for-box①">box</a> or <a data-link-type="dfn" href="https://drafts.csswg.org/css-break-4/#box-fragment" id="ref-for-box-fragment①">box fragment</a>, its <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box">boundary box</a></p> <li data-md> <p>otherwise, the <a data-link-type="dfn" href="https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region" id="ref-for-optimal-viewing-region①">optimal viewing region</a> of its 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></p> </ul> <p class="note" role="note"><span class="marker">NOTE:</span> If an object is offscreen, the <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area">inside area</a> should be the nearest visible ancestor container.</p> <p class="issue" id="issue-c7f6d991"><a class="self-link" href="#issue-c7f6d991"></a> CSS should have a term for “border box taking into account corner shaping properties like border-radius”. <a href="https://github.com/w3c/csswg-drafts/issues/2324">[w3c/csswg-drafts Issue #2324]</a></p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="search-origin">search origin</dfn> is the origin for searching next target.</p> <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="spatial-navigation-starting-point">spatial navigation starting point</dfn> is the origin for searching next target which is set by the user agent. It is initially unset and it can be element or point.</p> <p class="note" role="note"><span class="marker">Note:</span> For example, the user agent could set it to the position of the user’s click if the user clicks on the document contents, and unset when the focus is moved (by spatial navigation or any other means).</p> <p>If the user agent sets both a <a data-link-type="dfn" href="#spatial-navigation-starting-point" id="ref-for-spatial-navigation-starting-point">spatial navigation starting point</a> and a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-starting-point" id="ref-for-sequential-focus-navigation-starting-point">sequential focus navigation starting point</a>, they must not be set differently.</p> <h3 class="heading settled" data-level="8.2" id="grouping"><span class="secno">8.2. </span><span class="content"> Groupings of elements</span><a class="self-link" href="#grouping"></a></h3> <p>While the processing model for spatial navigation is to work from the layout of the document and the relative position of focusable elements, the user agent is required to prioritize finding elements from a local logical grouping, only looking for focusable elements outside of the grouping if a suitable one cannot be found inside it (see <a href="#nav">§ 8.3 Navigation</a> for details).</p> <p>Such groupings are called <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="spatial-navigation-containers">spatial navigation containers</dfn>.</p> <p><span class="cssapi">By default, </span><a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②④">spatial navigation containers</a> are established by:</p> <ul> <li data-md> <p>The viewport of a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context" id="ref-for-browsing-context①">browsing context</a> (not limited to the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context" id="ref-for-top-level-browsing-context②">top-level browsing context</a>)</p> <li data-md> <p><a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container④">scroll containers</a></p> </ul> <div class="cssapi"> Additional <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⑤">spatial navigation containers</a> can be created using the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain②">spatial-navigation-contain</a> property (see <a href="#container">§ 9.1 Creating additional spatial navigation containers: the spatial-navigation-contain property</a>). </div> <h3 class="heading settled" data-level="8.3" id="nav"><span class="secno">8.3. </span><span class="content"> Navigation</span><a class="self-link" href="#nav"></a></h3> <p>The processing model for spatial navigation describes how spatial navigation works in general.</p> <figure class="verbose non-normative"> <object data="images/spatnav_processing_model_diagram.svg" type="image/svg+xml"></object> <figcaption> Overview of the Spatial navigation processing model <br> This figure is not normative. It gives an overview of the processing model further defined in this section, assuming that the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action①">spatial-navigation-action</a> property has its initial value of <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-auto" id="ref-for-valdef-spatial-navigation-action-auto">auto</a>. </figcaption> </figure> <div class="algorithm" data-algorithm="to run the spatial navigation steps"> <p>To run the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport id="spatial-navigation-steps">spatial navigation steps</dfn> in <var>direction</var>, do the following:</p> <ol> <li data-md> <p>Let <var>searchOrigin</var> be the result of <a data-link-type="dfn" href="#set-the-search-origin" id="ref-for-set-the-search-origin">setting the search origin</a>.</p> <li data-md> <ul> <li data-md> <p>If <var>searchOrigin</var> is an <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#boundary-point-node" id="ref-for-boundary-point-node">node</a>, let <var>eventTarget</var> be <var>searchOrigin</var></p> <li data-md> <p>else (<a data-link-type="dfn" href="https://infra.spec.whatwg.org/#assert" id="ref-for-assert">assert</a>: <var>searchOrigin</var> is a position) let <var>eventTarget</var> be the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#boundary-point-node" id="ref-for-boundary-point-node①">node</a> which contains <var>searchOrigin</var></p> </ul> <li data-md> <p>If <var>eventTarget</var> is the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#clone-a-node-document" id="ref-for-clone-a-node-document②">Document</a> or the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#document-element" id="ref-for-document-element">document element</a>, set <var>eventTarget</var> be <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2" id="ref-for-the-body-element-2②">the body element</a> if it is not <code>null</code> or to the <span id="ref-for-document-element①">document element</span> otherwise.</p> <li data-md> <ul> <li class="cssapi">If <var>eventTarget</var> is <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑤">scroll container</a> and the computed value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action②">spatial-navigation-action</a> property on <var>eventTarget</var> is <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-scroll" id="ref-for-valdef-spatial-navigation-action-scroll">scroll</a> and <var>eventTarget</var> <a data-link-type="dfn" href="#can-be-manually-scrolled" id="ref-for-can-be-manually-scrolled">can be manually scrolled</a>, then <a data-link-type="dfn" href="#directionally-scroll-an-element" id="ref-for-directionally-scroll-an-element">directionally scroll the element</a> <var>eventTarget</var> and return. <li> <span class="cssapi">Else,</span> if <var>eventTarget</var> is either a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container⑥">scroll container</a> or the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#clone-a-node-document" id="ref-for-clone-a-node-document③">document</a> <ol> <li data-md> <p>Let <var>candidates</var> be the result of <a data-link-type="dfn" href="#find-focusable-areas" id="ref-for-find-focusable-areas②">finding focusable areas</a> within <var>eventTarget</var> with the argument <var>visibleOnly</var> set to <code>false</code> <span class="cssapi">if computed value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action③">spatial-navigation-action</a> property on <var>eventTarget</var> is <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus">focus</a> or to <code>true</code> otherwise. </span></p> <li data-md> <ul> <li class="cssapi">If the computed value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action④">spatial-navigation-action</a> property on <var>eventTarget</var> is not <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus①">focus</a> and <var>eventTarget</var> <a data-link-type="dfn" href="#can-be-manually-scrolled" id="ref-for-can-be-manually-scrolled①">can be manually scrolled</a>, then <a data-link-type="dfn" href="#directionally-scroll-an-element" id="ref-for-directionally-scroll-an-element①">directionally scroll the element</a> <var>eventTarget</var> in <var>direction</var> and return. <li> <span class="cssapi">Else </span>if <var>candidates</var> contains at least 1 item: <ol> <li data-md> <p>Let <var>bestCandidate</var> be the result of <a data-link-type="dfn" href="#select-the-best-candidate" id="ref-for-select-the-best-candidate②">selecting the best candidate</a> within <var>candidates</var> in <var>direction</var> starting from <var>searchOrigin</var></p> <li data-md> <p><a data-link-type="dfn" href="#dispatches-navbeforefocus-event" id="ref-for-dispatches-navbeforefocus-event">Dispatches navbeforefocus event</a> at <var>eventTarget</var> with <var>direction</var> and <var>bestCandidate</var>.</p> <li data-md> <p>Run the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps" id="ref-for-focusing-steps">focusing steps</a> for <var>bestCandidate</var> and return</p> </ol> <li>Else, fall back to the next step. </ul> </ol> <li>Else, fall back to the next step. </ul> <li data-md> <p>Let <var>container</var> be the nearest ancestor of <var>eventTarget</var> that is a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⑥">spatial navigation container</a>.</p> <li data-md> <p><i>Loop</i>: Let <var>candidates</var> be the result of <a data-link-type="dfn" href="#find-focusable-areas" id="ref-for-find-focusable-areas③">finding focusable areas</a> within <var>container</var> with the argument <var>visibleOnly</var> set to <code>false</code> <span class="cssapi"> if computed value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action⑤">spatial-navigation-action</a> property on <var>container</var> is <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus②">focus</a> or to <code>true</code> otherwise, excluding <var>eventTarget</var> </span></p> <li data-md> <p>If <var>candidates</var> is empty:</p> <li class="cssapi">If the computed value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action⑥">spatial-navigation-action</a> property on <var>container</var> is not <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus③">focus</a> and <var>container</var> 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> that <a data-link-type="dfn" href="#can-be-manually-scrolled" id="ref-for-can-be-manually-scrolled②">can be manually scrolled</a>, <a data-link-type="dfn" href="#directionally-scroll-an-element" id="ref-for-directionally-scroll-an-element②">directionally scroll the element</a> <var>container</var> in <var>direction</var> and return. <li class="cssapi">Else, <ol> <li data-md> <p><a data-link-type="dfn" href="#dispatches-navnotarget-event" id="ref-for-dispatches-navnotarget-event">Dispatches navnotarget event</a> at <var>eventTarget</var> with <var>direction</var> and <var>container</var>.</p> <li data-md> <ul> <li data-md> <p>If <var>container</var> is the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#document-element" id="ref-for-document-element②">document element</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context" id="ref-for-top-level-browsing-context③">top-level browsing context</a>, then return. The user agent may transfer focus to its own controls (if any) honouring <var>direction</var>.</p> <li data-md> <p>Else, if <var>container</var> is the <a data-link-type="dfn" href="https://dom.spec.whatwg.org/#document-element" id="ref-for-document-element③">document element</a> of a <a data-link-type="dfn">nested browsing context</a> then:</p> <ol> <li data-md> <p>Set <var>searchOrigin</var> to <var>container</var>’s <a data-link-type="dfn">browsing context container</a></p> <li data-md> <p>Set <var>eventTarget</var> be <var>searchOrigin</var></p> <li data-md> <p>Set <var>container</var> to the nearest ancestor of <var>eventTarget</var> that is a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⑦">spatial navigation container</a>.</p> <li data-md> <p>Return to the step labeled <i>loop</i>.</p> </ol> <li data-md> <p>Else, set <var>container</var> to its closest ancestor that is itself a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⑧">spatial navigation container</a> and return to the step labeled <i>loop</i>.</p> </ul> </ol> <li data-md> <p>Let <var>bestCandidate</var> be the result of <a data-link-type="dfn" href="#select-the-best-candidate" id="ref-for-select-the-best-candidate③">selecting the best candidate</a> within <var>candidates</var> in <var>direction</var> starting from <var>eventTarget</var>.</p> <li data-md> <p><a data-link-type="dfn" href="#dispatches-navbeforefocus-event" id="ref-for-dispatches-navbeforefocus-event①">Dispatches navbeforefocus event</a> at <var>eventTarget</var> with <var>direction</var> and <var>bestCandidate</var>.</p> <li data-md> <p>Run the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps" id="ref-for-focusing-steps①">focusing steps</a> for <var>bestCandidate</var> and return.</p> </ol> </div> <h3 class="heading settled" data-level="8.4" id="heuristics"><span class="secno">8.4. </span><span class="content"> Focus Navigation Heuristics</span><a class="self-link" href="#heuristics"></a></h3> <p class="note" role="note"><span class="marker">Note:</span> The following algorithms are inspired from Chrome’s implementation as well as from the <a href="https://www.w3.org/TR/WICD/#focus-handling">old WICD Spec</a>. Implementors who find better approaches or refinements to these approaches are strongly encouraged to provide feedback and help improve this specification in order to maximize interoperability. In particular, divergences in how user agents <a data-link-type="dfn" href="#find-focusable-areas" id="ref-for-find-focusable-areas④">find focusable areas</a> may cause some elements to be focusable in some user agents but not in others, which would be bad for users.</p> <p>All geometrical operations in this section are defined to work on the result of CSS layout, including all graphical transformations, such as <a data-link-type="dfn" href="https://www.w3.org/TR/CSS2/visuren.html#x34" id="ref-for-x34">relative positioning</a> or <a data-link-type="biblio" href="#biblio-css-transforms-1" title="CSS Transforms Module Level 1">[CSS-TRANSFORMS-1]</a>.</p> <div class="algorithm" data-algorithm="to set the search origin"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="set the search origin | setting the search origin" data-noexport id="set-the-search-origin">set the <a data-link-type="dfn" href="#search-origin" id="ref-for-search-origin">search origin</a></dfn>, run the following steps:</p> <ol> <li data-md> <p>Let <var>searchOrigin</var> be the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor" id="ref-for-dom-anchor">DOM anchor</a> of the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context" id="ref-for-currently-focused-area-of-a-top-level-browsing-context">currently focused area of a top-level browsing context</a>.</p> <li data-md> <p>If the <a data-link-type="dfn" href="#spatial-navigation-starting-point" id="ref-for-spatial-navigation-starting-point①">spatial navigation starting point</a> is not <code>null</code> and it is inside <var>searchOrigin</var>, then return it.</p> <li data-md> <p>Otherwise, return <var>searchOrigin</var>.</p> </ol> <p>If the status of <var>focus target</var> changed not by moving the focus, <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="update the search origin | updating the search origin" data-noexport id="update-the-search-origin">update the <a data-link-type="dfn" href="#search-origin" id="ref-for-search-origin①">search origin</a></dfn> as following:</p> <ol> <li data-md> <p>If <var>focus target</var> becomes <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled" id="ref-for-concept-element-disabled">actually disabled</a> or <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#expressly-inert" id="ref-for-expressly-inert">expressly inert</a> or not <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/rendering.html#being-rendered" id="ref-for-being-rendered">being rendered</a>, then let <var>searchOrigin</var> be the <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①">boundary box</a> of <var>focus target</var>.</p> <li data-md> <p>If <var>focus target</var> is <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/infrastructure.html#nodes-are-removed" id="ref-for-nodes-are-removed">removed</a>, then let <var>searchOrigin</var> be the <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box②">boundary box</a> of <var>focus target</var> with the position of <var>focus target</var> when it existed.</p> <li data-md> <p>If <var>focus target</var> is completely off-screen, then let <var>searchOrigin</var> be the viewport of <var>focus target</var>’s nearest visible <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers②⑨">spatial navigation container</a>.</p> </ol> <p class="note" role="note"><span class="marker">NOTE:</span> The user agent should <a data-link-type="dfn" href="#update-the-search-origin" id="ref-for-update-the-search-origin">update the search origin</a>, for example, when the focused element was scrolled out by mouse scrolling or vanished from the viewport.</p> </div> <div class="algorithm" data-algorithm="to find focusable areas"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="find focusable areas | finding focusable areas" data-noexport id="find-focusable-areas">find focusable areas</dfn> within a containing element <var>C</var>, with an optional <var>visibleOnly</var> argument that defaults to <code>true</code>, run the following steps:</p> <ol> <li data-md> <p>Let <var>focusables</var> be the <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-set" id="ref-for-ordered-set">set</a> of all the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#focusable-area" id="ref-for-focusable-area②">focusable areas</a> whose <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor" id="ref-for-dom-anchor①">DOM anchor</a> are descendants of <var>C</var>. In the case of <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#box" id="ref-for-box②">boxes</a> with several <a data-link-type="dfn" href="https://drafts.csswg.org/css-break-4/#box-fragment" id="ref-for-box-fragment②">box fragments</a>, each <span id="ref-for-box-fragment③">box fragment</span> is considered separately.</p> <li data-md> <p>The user agent should <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-remove" id="ref-for-list-remove">remove</a> from <var>focusables</var> items that have a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor" id="ref-for-dom-anchor②">DOM anchor</a> whose <a data-link-type="element-attr" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex" id="ref-for-attr-tabindex"><code>tabindex</code></a> attribute is set to a negative value.</p> <p class="note" role="note"><span class="marker">Note:</span> This is a "SHOULD" in order to mirror the exclusion of elements with negative tabindex from the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-order" id="ref-for-sequential-focus-navigation-order">sequential focus navigation order</a> as defined in <a data-link-type="dfn" data-refhint-key="8c63e993" href="https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex" id="ref-for-attr-tabindex①">tabindex</a>.</p> <li data-md> <p>If <var>visibleOnly</var> is <code>false</code>, return <var>focusables</var>.</p> <p class="note" role="note"><span class="marker">Note:</span> <var>focusables</var> may be empty</p> <li data-md> <p>Let <var>visibles</var> be the subset of items in <var>focusables</var> whose <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box③">boundary box</a> is at least partly within the <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area①">inside area</a> of <var>C</var>.</p> <div class="advisement non-normative"> Except for elements that are in the currently non visible part of a scroller, spatial navigation does not automatically exclude elements which cannot be clicked on, for example, due to being obscured by some other element. To avoid breaking assumptions in the application logic if a user actually focuses and activates such an element, and to avoid confusing users by focusing invisible or apparently unreachable elements, the author should use make these elements unreachable to spatial navigation using the same best practices as for making elements unreachable to sequential navigation, such as using <code>tab-index="-1"</code> or the <a href="https://github.com/WICG/inert"><code>inert</code></a> attribute. </div> <li data-md> <p>Return <var>visibles</var>.</p> <p class="note" role="note"><span class="marker">Note:</span> <var>visibles</var> may be empty</p> </ol> </div> <div class="algorithm" data-algorithm="to select the best candidate"> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="select the best candidate | selecting the best candidate" data-noexport id="select-the-best-candidate">select the best candidate</dfn> within a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-set" id="ref-for-ordered-set①">set</a> of <var>candidates</var> in a direction <var>dir</var>, starting from <var>searchOrigin</var>, run the following steps:</p> <ol> <li data-md> <p>If <var>candidates</var> is <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#list-empty" id="ref-for-list-empty">empty</a>, return <code>null</code></p> <li data-md> <p>If <var>candidates</var> contains a single item, return that item</p> <li data-md> <p>Let <var>insiders</var> be the subset of <var>candidates</var></p> <ul> <li data-md> <p>whose boundary box fully overlaps with <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area②">inside area</a> of <var>searchOrigin</var></p> <li data-md> <p>whose boundary box partially overlaps with <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area③">inside area</a> of <var>searchOrigin</var> as</p> <ul> <li data-md> <p>top edge is below the top edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box④">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down">down</a></code></p> <li data-md> <p>bottom edge is above the bottom edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box⑤">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up">up</a></code></p> <li data-md> <p>right edge is left of the right edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box⑥">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left">left</a></code></p> <li data-md> <p>left edge is right of the left edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box⑦">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right">right</a></code></p> </ul> <p class="note" role="note"><span class="marker">NOTE:</span> More detail condition about how the element is overlapped with the search origin affects the sequence of focus movement. The sequence of focus movement is related to UX, so it depends on the UA-defined mechanism.</p> </ul> <p class="note" role="note"><span class="marker">Note:</span> this sub-setting is necessary to avoid going in the opposite direction than the one requested.</p> <li data-md> <ul> <li data-md> <p>If <var>insiders</var> is non empty,</p> <ol> <li data-md> <p>Let <var>closest subset</var> be the subset of <var>insiders</var> whose <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box⑧">boundary box</a>’s</p> <ul> <li data-md> <p>top edge is closest to the top edge of <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area④">inside area</a> of <var>searchOrigin</var> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down①">down</a></code></p> <li data-md> <p>bottom edge is closest to the bottom edge of <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area⑤">inside area</a> of <var>searchOrigin</var> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up①">up</a></code></p> <li data-md> <p>right edge is closest to the right edge of <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area⑥">inside area</a> of <var>searchOrigin</var> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left①">left</a></code></p> <li data-md> <p>left edge is closest to the left edge of <a data-link-type="dfn" href="#inside-area" id="ref-for-inside-area⑦">inside area</a> of <var>searchOrigin</var> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right①">right</a></code></p> </ul> <li data-md> <p>If <var>closest subset</var> contains a single item, return that item, else return the first item of <var>closest subset</var> in document order, unless its <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box⑨">boundary box</a> overlaps with the <span id="ref-for-boundary-box①⓪">boundary box</span> of another item and that item is higher in the CSS <a data-link-type="dfn" href="https://drafts.csswg.org/css2/zindex.html#painting-order" id="ref-for-painting-order">painting order</a>. In that case, return that item instead, unless it too is overlapped with another higher item, recursively.</p> </ol> <li data-md> <p>Else</p> <ol> <li data-md> <p>Set <var>candidates</var> be the subset of its items which satisfies one of the following conditions:</p> <ul> <li data-md> <p>the item doesn’t overlap with <var>searchOrigin</var> and its <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①①">boundary box</a>’s</p> <ul> <li data-md> <p>top edge is below the bottom edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①②">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down②">down</a></code></p> <li data-md> <p>bottom edge is above the top edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①③">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up②">up</a></code></p> <li data-md> <p>right edge is left of the left edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①④">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left②">left</a></code></p> <li data-md> <p>left edge is right of the right edge of <var>searchOrigin</var>’s <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①⑤">boundary box</a> if <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right②">right</a></code></p> </ul> </ul> <li data-md> <p>For each <var>candidate</var> in <var>candidates</var>, <a data-link-type="dfn" href="#find-the-shortest-distance" id="ref-for-find-the-shortest-distance">find the shortest distance</a> between <var>searchOrigin</var>.</p> <li data-md> <p>Return the item of the <var>candidates</var> set that has the smallest distance. If several have the same distance, return the first one in document order, unless its <a data-link-type="dfn" href="#boundary-box" id="ref-for-boundary-box①⑥">boundary box</a> overlaps with the <span id="ref-for-boundary-box①⑦">boundary box</span> of another item at the same distance, and that item is higher in the CSS <a data-link-type="dfn" href="https://drafts.csswg.org/css2/zindex.html#painting-order" id="ref-for-painting-order①">painting order</a>. In that case, return that item instead, unless it too is overlapped with another higher item at the same distance, recursively.</p> </ol> </ul> </ol> </div> <div class="algorithm" data-algorithm="to find the shortest the distance"> To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="find the shortest distance | finding the shortest distance" data-noexport id="find-the-shortest-distance">find the shortest distance</dfn> between a <var>reference</var> and a <var>candidate</var> in direction <var>dir</var>, find the points <var>P1</var> and <var>P2</var>, respectively within the boundary boxes of the <var>reference</var> and of the <var>candidate</var>, that minimize the <var>distance</var> as defined as below: <pre class="prod"><var>distance</var> = <var>euclidean</var> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-4/#mult-one-plus" id="ref-for-mult-one-plus">+</a> <var>displacement</var> - <var>alignment</var> - <var>sqrt(Overlap)</var> </pre> <p>The meaning of each term is as follows:</p> <dl> <dt><var>euclidean</var> <dd> The euclidean distance between <var>P1</var> and <var>P2</var> <dt><var>displacement</var> <dd> The degree of displacement in <var>dir</var> between the <var>reference</var> and the <var>candidate</var>, defined as <pre><code><var>displacement</var> = (absolute distance on the axis orthogonal to <var>dir</var> between <var>P1</var> and <var>P2</var> + <var>orthogonalBias</var>) * <var>orthogonalWeight</var> </code></pre> <dt><var>orthogonalBias</var>: <dd> <ul> <li data-md> <p>If the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left③">left</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right③">right</a></code>, the height of the axis-aligned bounding box of <var>reference</var> / 2</p> <li data-md> <p>Else if the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up③">up</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down③">down</a></code>, the width of the axis-aligned bounding box of <var>reference</var> / 2</p> </ul> <dt><var>orthogonalWeight</var>: <dd> <ul> <li data-md> <p>If the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left④">left</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right④">right</a></code>, 30</p> <li data-md> <p>Else if the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up④">up</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down④">down</a></code>, 2</p> </ul> <dt><var>alignment</var> <dd> The degree of alignment in <var>dir</var> between the <var>reference</var> and the <var>candidate</var>, defined as: <pre><code><var>alignment</var> = <var>alignBias</var> * <var>alignWeight</var> </code></pre> <dt><var>alignBias</var>: <dd> <ul> <li data-md> <p>If the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left⑤">left</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right⑤">right</a></code>, <var>projectedOverlap</var> / height of the axis-aligned bounding box of <var>reference</var></p> <li data-md> <p>Else if the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up⑤">up</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down⑤">down</a></code>, <var>projectedOverlap</var> / width of the axis-aligned bounding box of <var>reference</var></p> </ul> <dt><var>projectedOverlap</var>: <dd> <ul> <li data-md> <p>If the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-left" id="ref-for-dom-spatialnavigationdirection-left⑥">left</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-right" id="ref-for-dom-spatialnavigationdirection-right⑥">right</a></code>, the length of the overlap between the horizontal projections onto the vertical axis of the <var>reference</var> and the <var>candidate</var></p> <li data-md> <p>Else if the <var>dir</var> is <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-up" id="ref-for-dom-spatialnavigationdirection-up⑥">up</a></code> or <code class="idl"><a data-link-type="idl" href="#dom-spatialnavigationdirection-down" id="ref-for-dom-spatialnavigationdirection-down⑥">down</a></code>, the length of the overlap between the vertical projections onto the horizontal axis of the <var>reference</var> and the <var>candidate</var></p> </ul> <figure> <img alt height="483" src="images/projected_overlap.png" style="width: 500px;" width="1038"> <figcaption>projectedOverlap</figcaption> </figure> <dt><var>alignWeight</var>: <dd>5 <dt><var>sqrt(Overlap)</var> <dd> The square root of area of overlap between the <var>reference</var> and the <var>candidate</var>, or 0 if they do not overlap. </dl> <p class="note" role="note"><span class="marker">Note:</span> This general formula was picked from several plausible alternatives, based on which one most often matches intuition when used to select the best candidate in a series of <a href="https://wicg.github.io/spatial-navigation/tests/ux/list.html">UX test cases</a>. Similarly, the values of <var>alignWeight</var> and <var>orthogonalWeight</var> were also determined experimentally based on the same test cases. The resulting formula is somewhat complicated, but seems to give good answers. Suggestions for improvements or simplifications are welcome.</p> </div> <div class="cssapi"> <h2 class="heading settled" data-level="9" id="declarative"><span class="secno">9. </span><span class="content"> Controlling spatial navigation through declarative means</span><a class="self-link" href="#declarative"></a></h2> <h3 class="heading settled" data-level="9.1" id="container"><span class="secno">9.1. </span><span class="content"> Creating additional spatial navigation containers: the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain③">spatial-navigation-contain</a> property</span><a class="self-link" href="#container"></a></h3> <table class="def propdef" data-link-for-hint="spatial-navigation-contain"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-spatial-navigation-contain">spatial-navigation-contain</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> contain <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 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>as specified <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> <dl> <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-contain" data-dfn-type="value" data-export id="valdef-spatial-navigation-contain-auto">auto</dfn> <dd>If the element 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> then it establishes a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③⓪">spatial navigation container</a>, otherwise it does not. <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-contain" data-dfn-type="value" data-export id="valdef-spatial-navigation-contain-contain">contain</dfn> <dd>The element establishes a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③①">spatial navigation container</a> </dl> <p class="note" role="note"><span class="marker">Note:</span> In addition, as per <a href="#grouping">§ 8.2 Groupings of elements</a>, the viewport of a <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/browsers.html#browsing-context" id="ref-for-browsing-context②">browsing context</a> (not limited to the <a data-link-type="dfn" href="https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context" id="ref-for-top-level-browsing-context④">top-level browsing context</a>) also establishes a <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③②">spatial navigation container</a>.</p> <div class="example" id="example-f3404a68"> <a class="self-link" href="#example-f3404a68"></a> The following example shows a simplified TV program schedule or calendar. It has a grid of elements representing TV shows or calendar entries and some UI buttons around it. <p>In this case, the grid is quite sparse, so if the user tries to move down from "Foo", focus would be moved to "Next Week", as it is objectively closer in the down direction. The same is true for going down from "Bar": the focus would move to "Previous Week".</p> <div class="output"> <div id="example-cal"> <button>Previous Week</button> <table> <tbody> <tr> <td> <th>M <th>T <th>W <th>T <th>F <th>S <th>S <tr> <td>0-6 <td> <td> <td> <td> <td> <td> <td><a href="#">Foo</a> <tr> <td>6-9 <td><a href="#">Bar</a> <td> <td> <td> <td> <td> <td> <tr> <td>9-12 <td> <td><a href="#">Bat</a> <td> <td> <td> <td> <td> <tr> <td>12-18 <td> <td> <td> <td> <td> <td> <td> <tr> <td>18-21 <td> <td> <td> <td> <td> <td> <td><a href="#">Woo</a> <tr> <td>21-24 <td> <td> <td> <td> <td> <td><a href="#">Baz</a> <td> </table> <button>Next Week</button> </div> </div> <pre><code class="highlight"><c- p><</c-><c- f>div</c-><c- p>></c-> <c- p><</c-><c- f>button</c-><c- p>></c->Previous Week<c- p></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>table</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>th</c-><c- p>></c->M<c- p><</c-><c- f>th</c-><c- p>></c->T<c- p><</c-><c- f>th</c-><c- p>></c->W<c- p><</c-><c- f>th</c-><c- p>></c->T<c- p><</c-><c- f>th</c-><c- p>></c->F<c- p><</c-><c- f>th</c-><c- p>></c->S<c- p><</c-><c- f>th</c-><c- p>></c->S <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->0-6<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>"#"</c-><c- p>></c->Foo<c- p></</c-><c- f>a</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->6-9<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>"#"</c-><c- p>></c->Bar<c- p></</c-><c- f>a</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->9-12<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>"#"</c-><c- p>></c->Bat<c- p></</c-><c- f>a</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->12-18<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->18-21<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>"#"</c-><c- p>></c->Woo<c- p></</c-><c- f>a</c-><c- p>></c-> <c- p><</c-><c- f>tr</c-><c- p>><</c-><c- f>td</c-><c- p>></c->21-24<c- p><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>td</c-><c- p>><</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>"#"</c-><c- p>></c->Baz<c- p></</c-><c- f>a</c-><c- p>><</c-><c- f>td</c-><c- p>></c-> <c- p></</c-><c- f>table</c-><c- p>></c-> <c- p><</c-><c- f>button</c-><c- p>></c->Next Week<c- p></</c-><c- f>button</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </code></pre> <p>However, the author may want to provide a different navigation experience giving priority to movements inside the grid once you have focused one of its items because the elements in the table are semantically related to each other.</p> <p>Adding <code class="highlight">table <c- p>{</c-> <c- k>spatial-navigation-contain</c-><c- p>:</c-> contain<c- p>;</c-> <c- p>}</c-></code> to the stylesheet would result this behavior.</p> <p>After that, the focus would move down from "Foo" to "Woo" instead of "Next Week", and from "Bar" to "Bat" instead of "Previous Week".</p> <p>It would still be possible to move the focus out of the table. For example, the focus would move to "Next week" by going right from "Foo" since there is nothing in the grid that is to the right.</p> </div> <p class="note" role="note"><span class="marker">Note:</span> the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain④">spatial-navigation-contain</a> property is <a data-link-type="dfn" href="#at-risk" id="ref-for-at-risk①">at-risk</a>.</p> </div> <h3 class="heading settled" data-level="9.2" id="css-property-spatialnavigationaction"><span class="secno">9.2. </span><span class="content"> Controlling the interaction with scrolling: the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action⑦">spatial-navigation-action</a> property</span><a class="self-link" href="#css-property-spatialnavigationaction"></a></h3> <table class="def propdef" data-link-for-hint="spatial-navigation-action"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-spatial-navigation-action">spatial-navigation-action</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> focus <span id="ref-for-comb-one②">|</span> scroll <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>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>as specified <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 the focus is inside of a scroll container and the user triggers spatial navigation, it is somewhat ambiguous whether they are requesting that the focus be moved in that direction, or whether the document should be scrolled in that direction. By default, this is automatically determined, but this property allows the author to decide between focusing or scrolling.</p> <p>The precise behavior is defined in <a href="#nav">§ 8.3 Navigation</a>, but a high level description of the effect of each value is provided below.</p> <p>When spatial navigation is triggered, the behavior depends on the value of the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action⑧">spatial-navigation-action</a> on the currently focused element if that element 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>, or of its nearest <span id="ref-for-scroll-container①①">scroll container</span> ancestor if it isn’t.</p> <dl> <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-action" data-dfn-type="value" data-export id="valdef-spatial-navigation-action-auto">auto</dfn> <dd> If there are visible focusable elements 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> in the direction requested, the closest one becomes focused. Otherwise, the <span id="ref-for-scroll-container①③">scroll container</span> is scrolled in the direction requested. <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-action" data-dfn-type="value" data-export id="valdef-spatial-navigation-action-focus">focus</dfn> <dd> The focus is moved to the nearest focusable element 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>, regardless of whether it is visible. If there are none, the scroll container is <em>not</em> scrolled, and the search continues up the ancestry chain instead. <p class="note" role="note"><span class="marker">Note:</span> 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 be scrolled as a side effect of focusing an element which was previously not in view, but it will not <a data-link-type="dfn" href="#directionally-scroll-an-element" id="ref-for-directionally-scroll-an-element③">be directionally scrolled</a>.</p> <p class="note" role="note"><span class="marker">Note:</span> If the <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus④">focus</a> value is given to <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action⑨">spatial-navigation-action</a>, <a class="idl-code" data-link-type="event" href="#eventdef-navigationevent-navnotarget" id="ref-for-eventdef-navigationevent-navnotarget①">navnotarget</a> event occurs when there isn’t any visible candidate in the given direction within the viewport of the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③③">spatial navigation container</a> even if the container can be scrolled more.</p> <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-action" data-dfn-type="value" data-export id="valdef-spatial-navigation-action-scroll">scroll</dfn> <dd> If the currently focused element is not itself a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⑥">scroll container</a>, this value on an ancestor <span id="ref-for-scroll-container①⑦">scroll container</span> has the same effect as <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-auto" id="ref-for-valdef-spatial-navigation-action-auto①">auto</a>. <p>If the currently focused element 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>, it is scrolled in the direction requested without changing which element is in focus, regardless of the presence of focusable descendants.</p> <p class="note" role="note"><span class="marker">Note:</span> This means that spatial navigation can be used to move the focus to a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scroll-container" id="ref-for-scroll-container①⑨">scroll container</a> and to scroll it, but not to move the focus to its descendants. However, if the focus is moved to a descendant by some other mean (such as pressing the <span class="key">Tab</span> key or using the <<code class="idl"><a data-link-type="idl" href="https://html.spec.whatwg.org/multipage/interaction.html#dom-focus" id="ref-for-dom-focus②">focus()</a></code>> method) spatial navigation can be used to move the focus to other focusable descendants.</p> <p class="note" role="note"><span class="marker">Note:</span> The <span class="css">scroll</span> value is <a data-link-type="dfn" href="#at-risk" id="ref-for-at-risk②">at-risk</a>.</p> </dl> <p class="note" role="note"><span class="marker">Note:</span> Earlier version of this specification did not offer a declarative way to opt into the behavior defined by <a class="css" data-link-type="maybe" href="#valdef-spatial-navigation-action-focus" id="ref-for-valdef-spatial-navigation-action-focus⑤">focus</a>, and instead offered a cancellable event that would be fired before scrolling, so that the author could implement that behavior themselves. However, cancellable events related to scrolling can cause performance problems, so this event was removed and the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action①⓪">spatial-navigation-action</a> property was introduced instead.</p> <div class="example" id="example-59a246d8"> <a class="self-link" href="#example-59a246d8"></a> In this example, a scrollable container is specified with <code class="highlight"><c- k>spatial-navigation-action</c-><c- p>:</c-> focus</code>. Inside the container, there is an element which is out of the view within a <a data-link-type="dfn" href="https://drafts.csswg.org/css-overflow-3/#scrollport" id="ref-for-scrollport⑤">scrollport</a>. Pressing the down arrow key moves the focus directly to it without scrolling manually. <figure> <img alt height="611" src="images/spatnav-action.png" style="width: 500px;" width="750"> <figcaption>Moving focus from "Box 2" to "Box 3" without manually scrolling</figcaption> </figure> <pre><code class="highlight"><c- p><</c-><c- f>div</c-> <c- e>class</c-><c- o>=</c-><c- s>'scroller'</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>class</c-><c- o>=</c-><c- s>'item'</c-><c- p>></c->Box 1<c- p></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>class</c-><c- o>=</c-><c- s>'item'</c-><c- p>></c->Box 2<c- p></</c-><c- f>button</c-><c- p>></c-> <c- p><</c-><c- f>button</c-> <c- e>class</c-><c- o>=</c-><c- s>'item'</c-><c- p>></c->Box 3<c- p></</c-><c- f>button</c-><c- p>></c-> <c- p></</c-><c- f>div</c-><c- p>></c-> </code></pre> <pre><code class="highlight">.scroller <c- p>{</c-> <c- k>display</c-><c- p>:</c-> grid<c- p>;</c-> <c- k>grid-template-columns</c-><c- p>:</c-> <c- nf>repeat</c-><c- p>(</c-><c- m>1</c-><c- p>,</c-> <c- m>1</c-><c- k>fr</c-><c- p>);</c-> <c- k>height</c-><c- p>:</c-> <c- m>300</c-><c- k>px</c-><c- p>;</c-> <c- k>width</c-><c- p>:</c-> <c- m>200</c-><c- k>px</c-><c- p>;</c-> <c- k>overflow-y</c-><c- p>:</c-> scroll<c- p>;</c-> <c- k>spatial-navigation-action</c-><c- p>:</c-> focus<c- p>;</c-> <c- p>}</c-> .item <c- p>{</c-> <c- k>height</c-><c- p>:</c-> <c- m>100</c-><c- k>px</c-><c- p>;</c-> <c- k>width</c-><c- p>:</c-> <c- m>100</c-><c- k>px</c-><c- p>;</c-> <c- k>margin</c-><c- p>:</c-> <c- m>50</c-><c- k>px</c-> auto<c- p>;</c-> <c- k>background-color</c-><c- p>:</c-> blue<c- p>;</c-> <c- p>}</c-> :focus <c- p>{</c-> <c- k>background-color</c-><c- p>:</c-> red<c- p>;</c-> <c- p>}</c-> </code></pre> </div> <h3 class="heading settled" data-level="9.3" id="css-property-spatialnavigationfunction"><span class="secno">9.3. </span><span class="content"> Selecting the navigation algorithm: the <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-function" id="ref-for-propdef-spatial-navigation-function①">spatial-navigation-function</a> property</span><a class="self-link" href="#css-property-spatialnavigationfunction"></a></h3> <table class="def propdef" data-link-for-hint="spatial-navigation-function"> <tbody> <tr> <th>Name: <td><dfn class="dfn-paneled css" data-dfn-type="property" data-export id="propdef-spatial-navigation-function">spatial-navigation-function</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> grid <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 data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③④">spatial navigation 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>n/a <tr> <th><a href="https://www.w3.org/TR/css-cascade/#computed">Computed value:</a> <td>as specified <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 default algorithm of spatial navigation specified in the <a href="#processing-model">§ 8 Processing Model</a> may need the fine tune depending on the layout types. This property allows the author to indicate which navigation algorithm is reasonable for spatial navigation behavior.</p> <p>Its values are defined as follows:</p> <dl> <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-function" data-dfn-type="value" data-export id="valdef-spatial-navigation-function-normal">normal</dfn> <dd> Moves the focus with the default focus navigation algorithm defined by UA. <p>In general, the focus moves to the element with the closest distance calculated by <a data-link-type="dfn" href="#find-the-shortest-distance" id="ref-for-find-the-shortest-distance①">finding the shortest distance</a>.</p> <dt><dfn class="dfn-paneled css" data-dfn-for="spatial-navigation-function" data-dfn-type="value" data-export id="valdef-spatial-navigation-function-grid">grid</dfn> <dd> Moves the focus to the element which is aligned most in the navigation direction. <ul> <li data-md> <p>If there are more than one aligned candidates in the navigation direction, select the element with the closest distance along the axis which corresponds to the navigation direction. In case of multiple elements with the same distance, select the element with the minimum amount of alignment.</p> <li data-md> <p>Else if there isn’t any aligned candidate in a given direction, select the element with the closest distance along the axis which corresponds to the navigation direction. In case of multiple elements with the same distance, select the element with the minimum distance along the axis which is orthogonal to the navigation direction.</p> </ul> </dl> <p class="note" role="note"><span class="marker">NOTE:</span> These values are negotiated with the users' preferences which seems natural spatial navigation behavior for their pages.</p> <div class="example" id="example-c86d0d36"> <a class="self-link" href="#example-c86d0d36"></a> This example shows how the focus moves differently by the value of <code class="highlight">spatial-navigation-function</code>. <figure> <img alt height="450" src="images/spatnav-function.png" style="width: 500px;" width="554"> <figcaption>Moving focus from "A" to one of the candidate elements</figcaption> </figure> <p>Let the element which contains "A", "B" and "C" is the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③⑤">spatial navigation container</a>.</p> <p>When the user presses the down arrow key, if <code class="highlight">normal</code> value is given to <code class="highlight">spatial-navigation-function</code> of the element, the focus will move to "B". Otherwise, <code class="highlight">grid</code> value was specified to the element, the focus will move to "C".</p> </div> <h2 class="no-num heading settled" id="scrolling"><span class="content">Appendix A. Scroll extensions</span><a class="self-link" href="#scrolling"></a></h2> <p>This section proposes a few extensions to CSS that should be integrated in upstream specifications, but are hosted here until then.</p> <div class="algorithm" data-algorithm="can be manually scrolled"> <p class="issue" id="issue-942e7041"><a class="self-link" href="#issue-942e7041"></a> Terminology like this should be in <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a>, <a data-link-type="biblio" href="#biblio-css-overflow-3" title="CSS Overflow Module Level 3">[CSS-OVERFLOW-3]</a>, <a data-link-type="biblio" href="#biblio-css-scroll-snap-1" title="CSS Scroll Snap Module Level 1">[CSS-SCROLL-SNAP-1]</a>. <a href="https://github.com/w3c/csswg-drafts/issues/2322">[w3c/csswg-drafts Issue #2322]</a></p> <p>An element <var>e</var> <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="can be manually scrolled | can be scrolled manually | cannot be scrolled manually | cannot be manually scrolled" data-noexport id="can-be-manually-scrolled">can be manually scrolled</dfn> in a given direction <var>d</var> if:</p> <ul> <li data-md> <p>The <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-4/#principal-box" id="ref-for-principal-box">principal box</a> established by <var>e</var> 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>, and</p> <li data-md> <p>if <var>d</var> is <code>up</code> or <code>down</code>, the computed value of the <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow-y" id="ref-for-propdef-overflow-y">overflow-y</a> property is not <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden" id="ref-for-valdef-overflow-hidden">hidden</a>, and</p> <li data-md> <p>if <var>d</var> is <code>left</code> or <code>right</code>, the computed value of the <a class="property css" data-link-type="property" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow-x" id="ref-for-propdef-overflow-x">overflow-x</a> property is not <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden" id="ref-for-valdef-overflow-hidden①">hidden</a>, and</p> <li data-md> <p><var>e</var> is not at the <a data-link-type="dfn" href="https://drafts.csswg.org/css-overscroll-behavior-1/#scroll-boundary" id="ref-for-scroll-boundary">scroll boundary</a> in the direction <var>d</var></p> <li data-md> <p><var>e</var> is not snapped to the last <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-scroll-snap-1/#valdef-scroll-snap-type-mandatory" id="ref-for-valdef-scroll-snap-type-mandatory">mandatory</a> snap point in direction <var>d</var></p> </ul> </div> <div class="algorithm" data-algorithm="to directionally scroll an element"> <p class="issue" id="issue-00706fa4"><a class="self-link" href="#issue-00706fa4"></a> <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a> should probably define how to perform a scroll in a given direction without an explicit position. Until then, we roll our own. <a href="https://github.com/w3c/csswg-drafts/issues/2323">[w3c/csswg-drafts Issue #2323]</a></p> <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="directionally scroll an element | directionally scroll the element | be directionally scrolled" data-noexport id="directionally-scroll-an-element">directionally scroll an element</dfn> <var>e</var> in direction <var>dir</var>:</p> <ol> <li data-md> <p>Let <var>d</var> be a user agent defined distance.</p> <li data-md> <p>Let <var>x</var> be <var>e</var>’s current scroll position on the x axis.</p> <li data-md> <p>Let <var>y</var> be <var>e</var>’s current scroll position on the y axis.</p> <li data-md> <p>Use the <a data-link-type="dfn" href="https://drafts.csswg.org/cssom-view-1/#scroll-an-element" id="ref-for-scroll-an-element">scroll an element</a> algorithm from <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a> on <var>e</var> to</p> <ul> <li data-md> <p>(<var>x</var>, <var>y</var> - <var>d</var>) if <var>dir</var> is <code>up</code></p> <li data-md> <p>(<var>x</var>, <var>y</var> + <var>d</var>) if <var>dir</var> is <code>down</code></p> <li data-md> <p>(<var>x</var> - <var>d</var>, <var>y</var>) if <var>dir</var> is <code>left</code></p> <li data-md> <p>(<var>x</var> + <var>d</var>, <var>y</var>) if <var>dir</var> is <code>right</code></p> </ul> </ol> </div> <h2 class="no-num heading settled" id="priv-sec"><span class="content"> Appendix B. Privacy and Security Considerations</span><a class="self-link" href="#priv-sec"></a></h2> <p>The specification contributors believe that all known potential security risks associated with this specification have been adequately addressed. Further details are provided below.</p> <p>The TAG has developed a self-review questionnaire to help editors and Working Groups evaluate the risks introduced by their specifications. Answers are provided below.</p> <dl> <dt>Does this specification deal with personally-identifiable information? <dd>No. <dt>Does this specification deal with high-value data? <dd>No. <dt>Does this specification introduce new state for an origin that persists across browsing sessions? <dd>No. <dt>Does this specification expose persistent, cross-origin state to the web? <dd>No. <dt>Does this specification expose any other data to an origin that it doesn’t currently have access to? <dd> Mostly, no. <p>The one exception identified would be in the following scenario: if the author uses `window.navigate` while the focus is in a cross origin iframe, if they don’t get an event at all it means that either there was something scrollable or focusable within the iframe, as the only case where they’d get an event is when the search didn’t find anything at all goes up the tree.</p> <p>This is so limited information that it does not seem it would introduces real a security risk, but it is as far as the editors can tell information that the author could not get could not get otherwise.</p> <dt>Does this specification enable new script execution/loading mechanisms? <dd>No. <dt>Does this specification allow an origin access to a user’s location? <dd>No. <dt>Does this specification allow an origin access to sensors on a user’s device? <dd>No. <dt>Does this specification allow an origin access to aspects of a user’s local computing environment? <dd>No. <dt>Does this specification allow an origin access to other devices? <dd>No. <dt>Does this specification allow an origin some measure of control over a user agent’s native UI? <dd> No control is given over the appearance of the user agent’s UI. Some control is given over how the user agent performs spatial navigation, which may be considered part of its user interface. This is intentional, to let the author tailor the behavior of spatial navigation to their pages. To prevent malicious the author to interfere with the users' desire to control focus and navigate the document, this overriding mechanism is disabled by default for cross-origin iframes. See <a href="#policy-feature">§ 7 The navigation-override policy-controlled feature</a>. <dt>Does this specification expose temporary identifiers to the web? <dd>No. <dt>Does this specification distinguish between behavior in first-party and third-party contexts? <dd>No. <dt>How should this specification work in the context of a user agent’s "incognito" mode? <dd>No Difference. <dt>Does this specification persist data to a user’s local device? <dd>No. <dt>Does this specification have a "Security Considerations" and "Privacy Considerations" section? <dd>Yes, this is the section you are reading now. <dt>Does this specification allow downgrading default security characteristics? <dd> It does not allow downgrading any unrelated security mechanism. <p>It **does** allow the author to opt into allowing the events needed to override the default behavior of spatial navigation in cross origin iframes they trust using <a data-link-type="biblio" href="#biblio-feature-policy" title="Permissions Policy">[feature-policy]</a>. See <a href="#policy-feature">§ 7 The navigation-override policy-controlled feature</a>.</p> </dl> <h2 class="no-num heading settled" id="ack"><span class="content">Acknowledgements</span><a class="self-link" href="#ack"></a></h2> <p>The editors of this specification would like to thank the following individuals for their feedback and contributions (in alphabetical order):</p> <ul> <li data-md> <p>Alice Boxhall</p> <li data-md> <p>Brian Kardell</p> <li data-md> <p>Elika Etemad</p> <li data-md> <p>Eric Seong</p> <li data-md> <p>Hugo Holgersson</p> <li data-md> <p>Hyojin Song</p> <li data-md> <p>Jeonghee Ahn</p> <li data-md> <p>Junho Seo</p> <li data-md> <p>Rob Dodson</p> <li data-md> <p>Seungcheon Baek</p> </ul> <h2 class="no-num heading settled" id="changes"><span class="content">Changes</span><a class="self-link" href="#changes"></a></h2> <p><em>This section is non-normative.</em></p> <p>The following changes were made since the <a href="https://www.w3.org/TR/2019/WD-css-nav-1-20190423/">23 April 2019 First Public Working Draft</a>.</p> <ul> <li data-md> <p>Changed the result of <code class="idl"><a data-link-type="idl" href="#dom-element-getspatialnavigationcontainer" id="ref-for-dom-element-getspatialnavigationcontainer④">getSpatialNavigationContainer()</a></code> to return the nearest <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③⑥">spatial navigation container</a> ancestor</p> <li data-md> <p>Added <a class="property css" data-link-type="property" href="#propdef-spatial-navigation-function" id="ref-for-propdef-spatial-navigation-function②">spatial-navigation-function</a></p> <li data-md> <p>Added <a data-link-type="dfn" href="#update-the-search-origin" id="ref-for-update-the-search-origin①">updating the search origin</a> step</p> <li data-md> <p>Changed the IDL of <code class="idl"><a data-link-type="idl" href="#dom-element-spatialnavigationsearch" id="ref-for-dom-element-spatialnavigationsearch">spatialNavigationSearch()</a></code> as separating the dir attribute from <code class="idl"><a data-link-type="idl" href="#dictdef-spatialnavigationsearchoptions" id="ref-for-dictdef-spatialnavigationsearchoptions①">SpatialNavigationSearchOptions</a></code></p> <li data-md> <p>Made the focusable element fully overlapped with search origin which is not the <a data-link-type="dfn" href="#spatial-navigation-containers" id="ref-for-spatial-navigation-containers③⑦">spatial navigation container</a> as a candidate for fixing the unreachability</p> </ul> </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="#dom-focusableareasearchmode-all">"all"</a><span>, in § 5.2</span> <li><a href="#at-risk">at-risk</a><span>, in § 1</span> <li> auto <ul> <li><a href="#valdef-spatial-navigation-action-auto">value for spatial-navigation-action</a><span>, in § 9.2</span> <li><a href="#valdef-spatial-navigation-contain-auto">value for spatial-navigation-contain</a><span>, in § 9.1</span> </ul> <li><a href="#directionally-scroll-an-element">be directionally scrolled</a><span>, in § Unnumbered section</span> <li><a href="#boundary-box">boundary box</a><span>, in § 8.1</span> <li><a href="#can-be-manually-scrolled">can be manually scrolled</a><span>, in § Unnumbered section</span> <li><a href="#can-be-manually-scrolled">can be scrolled manually</a><span>, in § Unnumbered section</span> <li><a href="#dom-spatialnavigationsearchoptions-candidates">candidates</a><span>, in § 5.2</span> <li><a href="#can-be-manually-scrolled">cannot be manually scrolled</a><span>, in § Unnumbered section</span> <li><a href="#can-be-manually-scrolled">cannot be scrolled manually</a><span>, in § Unnumbered section</span> <li><a href="#dom-navigationevent-navigationevent">constructor(type)</a><span>, in § 6.1</span> <li><a href="#dom-navigationevent-navigationevent">constructor(type, eventInitDict)</a><span>, in § 6.1</span> <li><a href="#valdef-spatial-navigation-contain-contain">contain</a><span>, in § 9.1</span> <li><a href="#dom-spatialnavigationsearchoptions-container">container</a><span>, in § 5.2</span> <li> dir <ul> <li><a href="#dom-navigationevent-dir">attribute for NavigationEvent</a><span>, in § 6.1</span> <li><a href="#dom-navigationeventinit-dir">dict-member for NavigationEventInit</a><span>, in § 6.1</span> </ul> <li><a href="#directionally-scroll-an-element">directionally scroll an element</a><span>, in § Unnumbered section</span> <li><a href="#directionally-scroll-an-element">directionally scroll the element</a><span>, in § Unnumbered section</span> <li><a href="#dispatches-navbeforefocus-event">dispatches navbeforefocus event</a><span>, in § 6.2.1</span> <li><a href="#dispatches-navnotarget-event">dispatches navnotarget event</a><span>, in § 6.2.2</span> <li><a href="#dispatches-navbeforefocus-event">dispatching navbeforefocus event</a><span>, in § 6.2.1</span> <li><a href="#dispatches-navnotarget-event">dispatching navnotarget event</a><span>, in § 6.2.2</span> <li><a href="#dom-spatialnavigationdirection-down">"down"</a><span>, in § 5.1</span> <li><a href="#find-focusable-areas">find focusable areas</a><span>, in § 8.4</span> <li><a href="#find-focusable-areas">finding focusable areas</a><span>, in § 8.4</span> <li><a href="#find-the-shortest-distance">finding the shortest distance</a><span>, in § 8.4</span> <li><a href="#find-the-shortest-distance">find the shortest distance</a><span>, in § 8.4</span> <li><a href="#valdef-spatial-navigation-action-focus">focus</a><span>, in § 9.2</span> <li><a href="#dom-element-focusableareas">focusableAreas()</a><span>, in § 5.2</span> <li><a href="#enumdef-focusableareasearchmode">FocusableAreaSearchMode</a><span>, in § 5.2</span> <li><a href="#dom-element-focusableareas">focusableAreas(option)</a><span>, in § 5.2</span> <li><a href="#dictdef-focusableareasoption">FocusableAreasOption</a><span>, in § 5.2</span> <li><a href="#dom-element-getspatialnavigationcontainer">getSpatialNavigationContainer()</a><span>, in § 5.2</span> <li><a href="#valdef-spatial-navigation-function-grid">grid</a><span>, in § 9.3</span> <li><a href="#inside-area">inside area</a><span>, in § 8.1</span> <li><a href="#dom-spatialnavigationdirection-left">"left"</a><span>, in § 5.1</span> <li><a href="#dom-focusableareasoption-mode">mode</a><span>, in § 5.2</span> <li><a href="#eventdef-navigationevent-navbeforefocus">navbeforefocus</a><span>, in § 6.2.1</span> <li><a href="#dom-window-navigate">navigate(dir)</a><span>, in § 5.1</span> <li><a href="#navigationevent">NavigationEvent</a><span>, in § 6.1</span> <li><a href="#dictdef-navigationeventinit">NavigationEventInit</a><span>, in § 6.1</span> <li><a href="#dom-navigationevent-navigationevent">NavigationEvent(type)</a><span>, in § 6.1</span> <li><a href="#dom-navigationevent-navigationevent">NavigationEvent(type, eventInitDict)</a><span>, in § 6.1</span> <li><a href="#navigation-override">navigation-override</a><span>, in § 7</span> <li><a href="#eventdef-navigationevent-navnotarget">navnotarget</a><span>, in § 6.2.2</span> <li><a href="#valdef-spatial-navigation-function-normal">normal</a><span>, in § 9.3</span> <li> relatedTarget <ul> <li><a href="#dom-navigationevent-relatedtarget">attribute for NavigationEvent</a><span>, in § 6.1</span> <li><a href="#dom-navigationeventinit-relatedtarget">dict-member for NavigationEventInit</a><span>, in § 6.1</span> </ul> <li><a href="#dom-spatialnavigationdirection-right">"right"</a><span>, in § 5.1</span> <li><a href="#valdef-spatial-navigation-action-scroll">scroll</a><span>, in § 9.2</span> <li><a href="#search-origin">search origin</a><span>, in § 8.1</span> <li><a href="#select-the-best-candidate">selecting the best candidate</a><span>, in § 8.4</span> <li><a href="#select-the-best-candidate">select the best candidate</a><span>, in § 8.4</span> <li><a href="#set-the-search-origin">set the search origin</a><span>, in § 8.4</span> <li><a href="#set-the-search-origin">setting the search origin</a><span>, in § 8.4</span> <li><a href="#spatial-navigation">spatial navigation</a><span>, in § 1</span> <li><a href="#spatial-navigation">spatialNavigation</a><span>, in § 1</span> <li><a href="#propdef-spatial-navigation-action">spatial-navigation-action</a><span>, in § 9.2</span> <li><a href="#propdef-spatial-navigation-contain">spatial-navigation-contain</a><span>, in § 9.1</span> <li><a href="#spatial-navigation-containers">spatial navigation containers</a><span>, in § 8.2</span> <li><a href="#enumdef-spatialnavigationdirection">SpatialNavigationDirection</a><span>, in § 5.1</span> <li><a href="#propdef-spatial-navigation-function">spatial-navigation-function</a><span>, in § 9.3</span> <li><a href="#dom-element-spatialnavigationsearch">spatialNavigationSearch(dir)</a><span>, in § 5.2</span> <li><a href="#dom-element-spatialnavigationsearch">spatialNavigationSearch(dir, options)</a><span>, in § 5.2</span> <li><a href="#dom-element-spatialnavigationsearch-options">spatialNavigationSearch(options)</a><span>, in § 5.2</span> <li><a href="#dictdef-spatialnavigationsearchoptions">SpatialNavigationSearchOptions</a><span>, in § 5.2</span> <li><a href="#spatial-navigation-starting-point">spatial navigation starting point</a><span>, in § 8.1</span> <li><a href="#spatial-navigation-steps">spatial navigation steps</a><span>, in § 8.3</span> <li><a href="#dom-spatialnavigationdirection-up">"up"</a><span>, in § 5.1</span> <li><a href="#update-the-search-origin">update the search origin</a><span>, in § 8.4</span> <li><a href="#update-the-search-origin">updating the search origin</a><span>, in § 8.4</span> <li><a href="#dom-focusableareasearchmode-visible">"visible"</a><span>, in § 5.2</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-BREAK-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="c3bd6e1d">box fragment</span> </ul> <li> <a data-link-type="biblio">[CSS-CASCADE-5]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="d95397a7">all</span> </ul> <li> <a data-link-type="biblio">[CSS-DISPLAY-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="881c2f72">box</span> <li><span class="dfn-paneled" id="80eb9508">principal box</span> </ul> <li> <a data-link-type="biblio">[CSS-OVERFLOW-3]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="e8907287">hidden</span> <li><span class="dfn-paneled" id="24f4b323">overflow-x</span> <li><span class="dfn-paneled" id="9958418a">overflow-y</span> <li><span class="dfn-paneled" id="86923d07">scroll container</span> <li><span class="dfn-paneled" id="60bbf126">scrollport</span> </ul> <li> <a data-link-type="biblio">[CSS-SCROLL-SNAP-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="3e8c945c">mandatory</span> <li><span class="dfn-paneled" id="6c4f0e7b">optimal viewing region</span> </ul> <li> <a data-link-type="biblio">[CSS-VALUES-4]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="bedd9d42">+</span> <li><span class="dfn-paneled" id="358fd6ff">CSS-wide keywords</span> <li><span class="dfn-paneled" id="6ec67710">|</span> </ul> <li> <a data-link-type="biblio">[CSS2]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="79e75ff8">border box</span> <li><span class="dfn-paneled" id="ffc19957">painting order</span> <li><span class="dfn-paneled" id="f285fdb1">relative positioning</span> </ul> <li> <a data-link-type="biblio">[CSSOM-VIEW-1]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="86c9f150">scroll an element</span> </ul> <li> <a data-link-type="biblio">[DOM]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="296f3551">Element</span> <li><span class="dfn-paneled" id="129bdae8">Event</span> <li><span class="dfn-paneled" id="2bc0cdf4">EventTarget</span> <li><span class="dfn-paneled" id="96c16e60">Node</span> <li><span class="dfn-paneled" id="2e9f6464">canceled flag</span> <li><span class="dfn-paneled" id="a84c14c9">document</span> <li><span class="dfn-paneled" id="2f0ba72c">document element</span> <li><span class="dfn-paneled" id="d462b34f">node</span> <li><span class="dfn-paneled" id="5216e1a0">node document</span> <li><span class="dfn-paneled" id="fefe0433">preventDefault()</span> <li><span class="dfn-paneled" id="e8478f36">target</span> </ul> <li> <a data-link-type="biblio">[FEATURE-POLICY]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="5b7bc2f2">default allowlist</span> <li><span class="dfn-paneled" id="7b98a372">policy-controlled feature</span> </ul> <li> <a data-link-type="biblio">[HTML]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="5d7209e9">Window</span> <li><span class="dfn-paneled" id="35972864">active document</span> <li><span class="dfn-paneled" id="8a0a6c58">actually disabled</span> <li><span class="dfn-paneled" id="f8434dee">being rendered</span> <li><span class="dfn-paneled" id="faf954d6">browsing context</span> <li><span class="dfn-paneled" id="76404f73">currently focused area of a top-level browsing context</span> <li><span class="dfn-paneled" id="06834943">DOM anchor</span> <li><span class="dfn-paneled" id="1ea14ef5">expressly inert</span> <li><span class="dfn-paneled" id="d345f720">focus(options)</span> <li><span class="dfn-paneled" id="fad8924f">focusable area</span> <li><span class="dfn-paneled" id="fe07e8b2">focusing steps</span> <li><span class="dfn-paneled" id="086e3aff">origin</span> <li><span class="dfn-paneled" id="e93b53b9">removed</span> <li><span class="dfn-paneled" id="373fd089">sequential focus navigation order</span> <li><span class="dfn-paneled" id="e6ae10e4">sequential focus navigation starting point</span> <li><span class="dfn-paneled" id="96797491">tabindex</span> <li><span class="dfn-paneled" id="96797491①">tabindex <small>(for htmlsvg-global)</small></span> <li><span class="dfn-paneled" id="c51ad875">the body element</span> <li><span class="dfn-paneled" id="ae2a6342">top-level browsing context</span> </ul> <li> <a data-link-type="biblio">[INFRA]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="77b4c09a">assert</span> <li><span class="dfn-paneled" id="03afaf9c">empty</span> <li><span class="dfn-paneled" id="99c988d6">remove</span> <li><span class="dfn-paneled" id="15e48c39">set</span> </ul> <li> <a data-link-type="biblio">[OVERSCROLL-BEHAVIOR]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="86de04c0">scroll boundary</span> </ul> <li> <a data-link-type="biblio">[UIEVENTS]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="1fc098b2">KeyboardEvent</span> <li><span class="dfn-paneled" id="92000da2">UIEvent</span> <li><span class="dfn-paneled" id="7eb5078b">UIEventInit</span> <li><span class="dfn-paneled" id="7d32cd87">event target</span> <li><span class="dfn-paneled" id="1b33fddd">key</span> <li><span class="dfn-paneled" id="7bb88371">keydown</span> </ul> <li> <a data-link-type="biblio">[WEBIDL]</a> defines the following terms: <ul> <li><span class="dfn-paneled" id="8855a9aa">DOMString</span> <li><span class="dfn-paneled" id="889e932f">Exposed</span> <li><span class="dfn-paneled" id="9cce47fd">sequence</span> <li><span class="dfn-paneled" id="5f90bbfb">undefined</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-break-4">[CSS-BREAK-4] <dd>Rossen Atanassov; Elika Etemad. <a href="https://drafts.csswg.org/css-break-4/"><cite>CSS Fragmentation Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-break-4/">https://drafts.csswg.org/css-break-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>Elika Etemad; Tab Atkins Jr.. <a href="https://drafts.csswg.org/css-display/"><cite>CSS Display Module Level 4</cite></a>. URL: <a href="https://drafts.csswg.org/css-display/">https://drafts.csswg.org/css-display/</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-scroll-snap-1">[CSS-SCROLL-SNAP-1] <dd>Matt Rakow; et al. <a href="https://drafts.csswg.org/css-scroll-snap-1/"><cite>CSS Scroll Snap Module Level 1</cite></a>. URL: <a href="https://drafts.csswg.org/css-scroll-snap-1/">https://drafts.csswg.org/css-scroll-snap-1/</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-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-feature-policy">[FEATURE-POLICY] <dd>Ian Clelland. <a href="https://w3c.github.io/webappsec-permissions-policy/"><cite>Permissions Policy</cite></a>. URL: <a href="https://w3c.github.io/webappsec-permissions-policy/">https://w3c.github.io/webappsec-permissions-policy/</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-infra">[INFRA] <dd>Anne van Kesteren; Domenic Denicola. <a href="https://infra.spec.whatwg.org/"><cite>Infra Standard</cite></a>. Living Standard. URL: <a href="https://infra.spec.whatwg.org/">https://infra.spec.whatwg.org/</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-uievents">[UIEVENTS] <dd>Gary Kacmarcik; Travis Leithead. <a href="https://w3c.github.io/uievents/"><cite>UI Events</cite></a>. URL: <a href="https://w3c.github.io/uievents/">https://w3c.github.io/uievents/</a> <dt id="biblio-webidl">[WEBIDL] <dd>Edgar Chen; Timothy Gu. <a href="https://webidl.spec.whatwg.org/"><cite>Web IDL Standard</cite></a>. Living Standard. URL: <a href="https://webidl.spec.whatwg.org/">https://webidl.spec.whatwg.org/</a> </dl> <h3 class="no-num no-ref heading settled" id="informative"><span class="content">Informative References</span><a class="self-link" href="#informative"></a></h3> <dl> <dt id="biblio-css-transforms-1">[CSS-TRANSFORMS-1] <dd>Simon Fraser; et al. <a href="https://drafts.csswg.org/css-transforms/"><cite>CSS Transforms Module Level 1</cite></a>. URL: <a href="https://drafts.csswg.org/css-transforms/">https://drafts.csswg.org/css-transforms/</a> <dt id="biblio-extensible">[EXTENSIBLE] <dd><a href="https://extensiblewebmanifesto.org/"><cite>The Extensible Web Manifesto</cite></a>. 10 June 2013. URL: <a href="https://extensiblewebmanifesto.org/">https://extensiblewebmanifesto.org/</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 <tbody> <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-spatial-navigation-action" id="ref-for-propdef-spatial-navigation-action①①">spatial-navigation-action</a> <td>auto | focus | scroll <td>auto <td>scroll containers <td>no <td>n/a <td>discrete <td>per grammar <td>as specified <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-spatial-navigation-contain" id="ref-for-propdef-spatial-navigation-contain⑤">spatial-navigation-contain</a> <td>auto | contain <td>auto <td>all elements <td>no <td>n/a <td>discrete <td>per grammar <td>as specified <tr> <th scope="row"><a class="css" data-link-type="property" href="#propdef-spatial-navigation-function" id="ref-for-propdef-spatial-navigation-function③">spatial-navigation-function</a> <td>normal | grid <td>normal <td>spatial navigation containers <td>no <td>n/a <td>discrete <td>per grammar <td>as specified </table> </div> <h2 class="no-num no-ref heading settled" id="idl-index"><span class="content">IDL Index</span><a class="self-link" href="#idl-index"></a></h2> <pre class="idl highlight def"><c- b>enum</c-> <a href="#enumdef-spatialnavigationdirection"><code><c- g>SpatialNavigationDirection</c-></code></a> { <a href="#dom-spatialnavigationdirection-up"><code><c- s>"up"</c-></code></a>, <a href="#dom-spatialnavigationdirection-down"><code><c- s>"down"</c-></code></a>, <a href="#dom-spatialnavigationdirection-left"><code><c- s>"left"</c-></code></a>, <a href="#dom-spatialnavigationdirection-right"><code><c- s>"right"</c-></code></a>, }; <c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#window"><c- g>Window</c-></a> { <a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-undefined"><c- b>undefined</c-></a> <a class="idl-code" data-link-type="method" href="#dom-window-navigate"><c- g>navigate</c-></a>(<a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection"><c- n>SpatialNavigationDirection</c-></a> <a href="#dom-window-navigate-dir-dir"><code><c- g>dir</c-></code></a>); }; <c- b>enum</c-> <a href="#enumdef-focusableareasearchmode"><code><c- g>FocusableAreaSearchMode</c-></code></a> { <a href="#dom-focusableareasearchmode-visible"><code><c- s>"visible"</c-></code></a>, <a href="#dom-focusableareasearchmode-all"><code><c- s>"all"</c-></code></a> }; <c- b>dictionary</c-> <a href="#dictdef-focusableareasoption"><code><c- g>FocusableAreasOption</c-></code></a> { <a data-link-type="idl-name" href="#enumdef-focusableareasearchmode"><c- n>FocusableAreaSearchMode</c-></a> <a data-type="FocusableAreaSearchMode" href="#dom-focusableareasoption-mode"><code><c- g>mode</c-></code></a>; }; <c- b>dictionary</c-> <a href="#dictdef-spatialnavigationsearchoptions"><code><c- g>SpatialNavigationSearchOptions</c-></code></a> { <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence"><c- b>sequence</c-></a><<a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node"><c- n>Node</c-></a>>? <a data-type="sequence<Node>?" href="#dom-spatialnavigationsearchoptions-candidates"><code><c- g>candidates</c-></code></a>; <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node"><c- n>Node</c-></a>? <a data-type="Node?" href="#dom-spatialnavigationsearchoptions-container"><code><c- g>container</c-></code></a>; }; <c- b>partial</c-> <c- b>interface</c-> <a class="idl-code" data-link-type="interface" href="https://dom.spec.whatwg.org/#element"><c- g>Element</c-></a> { <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node"><c- n>Node</c-></a> <a class="idl-code" data-link-type="method" href="#dom-element-getspatialnavigationcontainer"><c- g>getSpatialNavigationContainer</c-></a>(); <a data-link-type="dfn" href="https://webidl.spec.whatwg.org/#idl-sequence"><c- b>sequence</c-></a><<a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node"><c- n>Node</c-></a>> <a class="idl-code" data-link-type="method" href="#dom-element-focusableareas"><c- g>focusableAreas</c-></a>(<c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-focusableareasoption"><c- n>FocusableAreasOption</c-></a> <a href="#dom-element-focusableareas-option-option"><code><c- g>option</c-></code></a> = {}); <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#node"><c- n>Node</c-></a>? <a href="#dom-element-spatialnavigationsearch"><code><c- g>spatialNavigationSearch</c-></code></a>(<a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection"><c- n>SpatialNavigationDirection</c-></a> <a href="#dom-element-spatialnavigationsearch-dir-options-dir"><code><c- g>dir</c-></code></a>, <c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-spatialnavigationsearchoptions"><c- n>SpatialNavigationSearchOptions</c-></a> <a href="#dom-element-spatialnavigationsearch-dir-options-options"><code><c- g>options</c-></code></a> = {}); }; [<a class="idl-code" data-link-type="extended-attribute" href="https://webidl.spec.whatwg.org/#Exposed"><c- g>Exposed</c-></a>=<c- n>Window</c->] <c- b>interface</c-> <a href="#navigationevent"><code><c- g>NavigationEvent</c-></code></a> : <a data-link-type="idl-name" href="https://w3c.github.io/uievents/#uievent"><c- n>UIEvent</c-></a> { <a href="#dom-navigationevent-navigationevent"><code><c- g>constructor</c-></code></a>(<a class="idl-code" data-link-type="interface" href="https://webidl.spec.whatwg.org/#idl-DOMString"><c- b>DOMString</c-></a> <a href="#dom-navigationevent-navigationevent-type-eventinitdict-type"><code><c- g>type</c-></code></a>, <c- b>optional</c-> <a data-link-type="idl-name" href="#dictdef-navigationeventinit"><c- n>NavigationEventInit</c-></a> <a href="#dom-navigationevent-navigationevent-type-eventinitdict-eventinitdict"><code><c- g>eventInitDict</c-></code></a> = {}); <c- b>readonly</c-> <c- b>attribute</c-> <a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection"><c- n>SpatialNavigationDirection</c-></a> <a data-readonly data-type="SpatialNavigationDirection" href="#dom-navigationevent-dir"><code><c- g>dir</c-></code></a>; <c- b>readonly</c-> <c- b>attribute</c-> <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget"><c- n>EventTarget</c-></a>? <a data-readonly data-type="EventTarget?" href="#dom-navigationevent-relatedtarget"><code><c- g>relatedTarget</c-></code></a>; }; <c- b>dictionary</c-> <a href="#dictdef-navigationeventinit"><code><c- g>NavigationEventInit</c-></code></a> : <a data-link-type="idl-name" href="https://w3c.github.io/uievents/#dictdef-uieventinit"><c- n>UIEventInit</c-></a> { <a data-link-type="idl-name" href="#enumdef-spatialnavigationdirection"><c- n>SpatialNavigationDirection</c-></a> <a data-type="SpatialNavigationDirection" href="#dom-navigationeventinit-dir"><code><c- g>dir</c-></code></a>; <a data-link-type="idl-name" href="https://dom.spec.whatwg.org/#eventtarget"><c- n>EventTarget</c-></a>? <a data-default="null" data-type="EventTarget?" href="#dom-navigationeventinit-relatedtarget"><code><c- g>relatedTarget</c-></code></a> = <c- b>null</c->; }; </pre> <h2 class="no-num no-ref heading settled" id="issues-index"><span class="content">Issues Index</span><a class="self-link" href="#issues-index"></a></h2> <div style="counter-reset:issue"> <div class="issue"> The name of this API is under discussion <a href="https://github.com/w3c/csswg-drafts/issues/3387">[Issue #3387]</a> <a class="issue-return" href="#issue-a5a227c8" title="Jump to section">↵</a></div> <div class="issue"> CSS should have a term for “border box taking into account corner shaping properties like border-radius”. <a href="https://github.com/w3c/csswg-drafts/issues/2324">[w3c/csswg-drafts Issue #2324]</a> <a class="issue-return" href="#issue-c7f6d991" title="Jump to section">↵</a></div> <div class="issue"> Terminology like this should be in <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a>, <a data-link-type="biblio" href="#biblio-css-overflow-3" title="CSS Overflow Module Level 3">[CSS-OVERFLOW-3]</a>, <a data-link-type="biblio" href="#biblio-css-scroll-snap-1" title="CSS Scroll Snap Module Level 1">[CSS-SCROLL-SNAP-1]</a>. <a href="https://github.com/w3c/csswg-drafts/issues/2322">[w3c/csswg-drafts Issue #2322]</a> <a class="issue-return" href="#issue-942e7041" title="Jump to section">↵</a></div> <div class="issue"> <a data-link-type="biblio" href="#biblio-cssom-view-1" title="CSSOM View Module">[CSSOM-VIEW-1]</a> should probably define how to perform a scroll in a given direction without an explicit position. Until then, we roll our own. <a href="https://github.com/w3c/csswg-drafts/issues/2323">[w3c/csswg-drafts Issue #2323]</a> <a class="issue-return" href="#issue-00706fa4" title="Jump to section">↵</a></div> </div> <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 = { "03afaf9c": {"dfnID":"03afaf9c","dfnText":"empty","external":true,"refSections":[{"refs":[{"id":"ref-for-list-empty"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://infra.spec.whatwg.org/#list-empty"}, "06834943": {"dfnID":"06834943","dfnText":"DOM anchor","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-anchor"},{"id":"ref-for-dom-anchor\u2460"},{"id":"ref-for-dom-anchor\u2461"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor"}, "086e3aff": {"dfnID":"086e3aff","dfnText":"origin","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-origin"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-concept-origin\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://html.spec.whatwg.org/multipage/browsers.html#concept-origin"}, "129bdae8": {"dfnID":"129bdae8","dfnText":"Event","external":true,"refSections":[{"refs":[{"id":"ref-for-event"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-event\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://dom.spec.whatwg.org/#event"}, "15e48c39": {"dfnID":"15e48c39","dfnText":"set","external":true,"refSections":[{"refs":[{"id":"ref-for-ordered-set"},{"id":"ref-for-ordered-set\u2460"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://infra.spec.whatwg.org/#ordered-set"}, "1b33fddd": {"dfnID":"1b33fddd","dfnText":"key","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-keyboardevent-key"}],"title":"6.2.1. \nnavbeforefocus"}],"url":"https://w3c.github.io/uievents/#dom-keyboardevent-key"}, "1ea14ef5": {"dfnID":"1ea14ef5","dfnText":"expressly inert","external":true,"refSections":[{"refs":[{"id":"ref-for-expressly-inert"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#expressly-inert"}, "1fc098b2": {"dfnID":"1fc098b2","dfnText":"KeyboardEvent","external":true,"refSections":[{"refs":[{"id":"ref-for-keyboardevent"}],"title":"6.2.1. \nnavbeforefocus"}],"url":"https://w3c.github.io/uievents/#keyboardevent"}, "24f4b323": {"dfnID":"24f4b323","dfnText":"overflow-x","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-overflow-x"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow-x"}, "296f3551": {"dfnID":"296f3551","dfnText":"Element","external":true,"refSections":[{"refs":[{"id":"ref-for-element"}],"title":"5.2. \nLow level APIs"}],"url":"https://dom.spec.whatwg.org/#element"}, "2bc0cdf4": {"dfnID":"2bc0cdf4","dfnText":"EventTarget","external":true,"refSections":[{"refs":[{"id":"ref-for-eventtarget"},{"id":"ref-for-eventtarget\u2460"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"https://dom.spec.whatwg.org/#eventtarget"}, "2e9f6464": {"dfnID":"2e9f6464","dfnText":"canceled flag","external":true,"refSections":[{"refs":[{"id":"ref-for-canceled-flag"}],"title":"4. \nTriggering Spatial Navigation"}],"url":"https://dom.spec.whatwg.org/#canceled-flag"}, "2f0ba72c": {"dfnID":"2f0ba72c","dfnText":"document element","external":true,"refSections":[{"refs":[{"id":"ref-for-document-element"},{"id":"ref-for-document-element\u2460"},{"id":"ref-for-document-element\u2461"},{"id":"ref-for-document-element\u2462"}],"title":"8.3. \nNavigation"}],"url":"https://dom.spec.whatwg.org/#document-element"}, "358fd6ff": {"dfnID":"358fd6ff","dfnText":"CSS-wide keywords","external":true,"refSections":[{"refs":[{"id":"ref-for-css-wide-keywords"}],"title":"2.1. \nCSS Property Value Definitions"}],"url":"https://drafts.csswg.org/css-values-4/#css-wide-keywords"}, "35972864": {"dfnID":"35972864","dfnText":"active document","external":true,"refSections":[{"refs":[{"id":"ref-for-nav-document"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-nav-document\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document"}, "373fd089": {"dfnID":"373fd089","dfnText":"sequential focus navigation order","external":true,"refSections":[{"refs":[{"id":"ref-for-sequential-focus-navigation-order"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-order"}, "3e8c945c": {"dfnID":"3e8c945c","dfnText":"mandatory","external":true,"refSections":[{"refs":[{"id":"ref-for-valdef-scroll-snap-type-mandatory"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-scroll-snap-1/#valdef-scroll-snap-type-mandatory"}, "5216e1a0": {"dfnID":"5216e1a0","dfnText":"node document","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-node-document"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-concept-node-document\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://dom.spec.whatwg.org/#concept-node-document"}, "5b7bc2f2": {"dfnID":"5b7bc2f2","dfnText":"default allowlist","external":true,"refSections":[{"refs":[{"id":"ref-for-default-allowlist"}],"title":"7. \nThe navigation-override policy-controlled feature"}],"url":"https://w3c.github.io/webappsec-feature-policy/#default-allowlist"}, "5d7209e9": {"dfnID":"5d7209e9","dfnText":"Window","external":true,"refSections":[{"refs":[{"id":"ref-for-window"}],"title":"5.1. \nTriggering Navigation Programmatically"}],"url":"https://html.spec.whatwg.org/multipage/nav-history-apis.html#window"}, "5f90bbfb": {"dfnID":"5f90bbfb","dfnText":"undefined","external":true,"refSections":[{"refs":[{"id":"ref-for-idl-undefined"}],"title":"5.1. \nTriggering Navigation Programmatically"}],"url":"https://webidl.spec.whatwg.org/#idl-undefined"}, "60bbf126": {"dfnID":"60bbf126","dfnText":"scrollport","external":true,"refSections":[{"refs":[{"id":"ref-for-scrollport"},{"id":"ref-for-scrollport\u2460"},{"id":"ref-for-scrollport\u2461"}],"title":"3. \nOverview"},{"refs":[{"id":"ref-for-scrollport\u2462"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-scrollport\u2463"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-scrollport\u2464"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"https://drafts.csswg.org/css-overflow-3/#scrollport"}, "6c4f0e7b": {"dfnID":"6c4f0e7b","dfnText":"optimal viewing region","external":true,"refSections":[{"refs":[{"id":"ref-for-optimal-viewing-region"},{"id":"ref-for-optimal-viewing-region\u2460"}],"title":"8.1. \nGlossary"}],"url":"https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region"}, "6ec67710": {"dfnID":"6ec67710","dfnText":"|","external":true,"refSections":[{"refs":[{"id":"ref-for-comb-one"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"},{"refs":[{"id":"ref-for-comb-one\u2460"},{"id":"ref-for-comb-one\u2461"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"},{"refs":[{"id":"ref-for-comb-one\u2462"}],"title":"9.3. \nSelecting the navigation algorithm: the spatial-navigation-function property"}],"url":"https://drafts.csswg.org/css-values-4/#comb-one"}, "76404f73": {"dfnID":"76404f73","dfnText":"currently focused area of a top-level browsing context","external":true,"refSections":[{"refs":[{"id":"ref-for-currently-focused-area-of-a-top-level-browsing-context"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context"}, "77b4c09a": {"dfnID":"77b4c09a","dfnText":"assert","external":true,"refSections":[{"refs":[{"id":"ref-for-assert"}],"title":"8.3. \nNavigation"}],"url":"https://infra.spec.whatwg.org/#assert"}, "79e75ff8": {"dfnID":"79e75ff8","dfnText":"border box","external":true,"refSections":[{"refs":[{"id":"ref-for-x14"}],"title":"8.1. \nGlossary"}],"url":"https://drafts.csswg.org/css2/box.html#x14"}, "7b98a372": {"dfnID":"7b98a372","dfnText":"policy-controlled feature","external":true,"refSections":[{"refs":[{"id":"ref-for-policy-controlled-feature"},{"id":"ref-for-policy-controlled-feature\u2460"}],"title":"7. \nThe navigation-override policy-controlled feature"}],"url":"https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature"}, "7bb88371": {"dfnID":"7bb88371","dfnText":"keydown","external":true,"refSections":[{"refs":[{"id":"ref-for-keydown"}],"title":"4. \nTriggering Spatial Navigation"}],"url":"https://w3c.github.io/uievents/#keydown"}, "7d32cd87": {"dfnID":"7d32cd87","dfnText":"event target","external":true,"refSections":[{"refs":[{"id":"ref-for-event-target"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-event-target\u2460"},{"id":"ref-for-event-target\u2461"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://w3c.github.io/uievents/#event-target"}, "7eb5078b": {"dfnID":"7eb5078b","dfnText":"UIEventInit","external":true,"refSections":[{"refs":[{"id":"ref-for-dictdef-uieventinit"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"https://w3c.github.io/uievents/#dictdef-uieventinit"}, "80eb9508": {"dfnID":"80eb9508","dfnText":"principal box","external":true,"refSections":[{"refs":[{"id":"ref-for-principal-box"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-display-4/#principal-box"}, "86923d07": {"dfnID":"86923d07","dfnText":"scroll container","external":true,"refSections":[{"refs":[{"id":"ref-for-scroll-container"},{"id":"ref-for-scroll-container\u2460"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-scroll-container\u2461"},{"id":"ref-for-scroll-container\u2462"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-scroll-container\u2463"}],"title":"8.2. \nGroupings of elements"},{"refs":[{"id":"ref-for-scroll-container\u2464"},{"id":"ref-for-scroll-container\u2465"},{"id":"ref-for-scroll-container\u2466"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-scroll-container\u2467"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"},{"refs":[{"id":"ref-for-scroll-container\u2468"},{"id":"ref-for-scroll-container\u2460\u24ea"},{"id":"ref-for-scroll-container\u2460\u2460"},{"id":"ref-for-scroll-container\u2460\u2461"},{"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"},{"id":"ref-for-scroll-container\u2460\u2467"},{"id":"ref-for-scroll-container\u2460\u2468"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"},{"refs":[{"id":"ref-for-scroll-container\u2461\u24ea"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-overflow-3/#scroll-container"}, "86c9f150": {"dfnID":"86c9f150","dfnText":"scroll an element","external":true,"refSections":[{"refs":[{"id":"ref-for-scroll-an-element"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/cssom-view-1/#scroll-an-element"}, "86de04c0": {"dfnID":"86de04c0","dfnText":"scroll boundary","external":true,"refSections":[{"refs":[{"id":"ref-for-scroll-boundary"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-overscroll-behavior-1/#scroll-boundary"}, "881c2f72": {"dfnID":"881c2f72","dfnText":"box","external":true,"refSections":[{"refs":[{"id":"ref-for-box"},{"id":"ref-for-box\u2460"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-box\u2461"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://drafts.csswg.org/css-display-4/#box"}, "8855a9aa": {"dfnID":"8855a9aa","dfnText":"DOMString","external":true,"refSections":[{"refs":[{"id":"ref-for-idl-DOMString"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"https://webidl.spec.whatwg.org/#idl-DOMString"}, "889e932f": {"dfnID":"889e932f","dfnText":"Exposed","external":true,"refSections":[{"refs":[{"id":"ref-for-Exposed"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"https://webidl.spec.whatwg.org/#Exposed"}, "8a0a6c58": {"dfnID":"8a0a6c58","dfnText":"actually disabled","external":true,"refSections":[{"refs":[{"id":"ref-for-concept-element-disabled"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled"}, "92000da2": {"dfnID":"92000da2","dfnText":"UIEvent","external":true,"refSections":[{"refs":[{"id":"ref-for-uievent"}],"title":"4. \nTriggering Spatial Navigation"},{"refs":[{"id":"ref-for-uievent\u2460"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"https://w3c.github.io/uievents/#uievent"}, "96797491": {"dfnID":"96797491","dfnText":"tabindex (for htmlsvg-global)","external":true,"refSections":[{"refs":[{"id":"ref-for-attr-tabindex"},{"id":"ref-for-attr-tabindex\u2460"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"}, "96c16e60": {"dfnID":"96c16e60","dfnText":"Node","external":true,"refSections":[{"refs":[{"id":"ref-for-node"},{"id":"ref-for-node\u2460"},{"id":"ref-for-node\u2461"},{"id":"ref-for-node\u2462"},{"id":"ref-for-node\u2463"}],"title":"5.2. \nLow level APIs"}],"url":"https://dom.spec.whatwg.org/#node"}, "9958418a": {"dfnID":"9958418a","dfnText":"overflow-y","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-overflow-y"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow-y"}, "99c988d6": {"dfnID":"99c988d6","dfnText":"remove","external":true,"refSections":[{"refs":[{"id":"ref-for-list-remove"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://infra.spec.whatwg.org/#list-remove"}, "9cce47fd": {"dfnID":"9cce47fd","dfnText":"sequence","external":true,"refSections":[{"refs":[{"id":"ref-for-idl-sequence"},{"id":"ref-for-idl-sequence\u2460"}],"title":"5.2. \nLow level APIs"}],"url":"https://webidl.spec.whatwg.org/#idl-sequence"}, "a84c14c9": {"dfnID":"a84c14c9","dfnText":"document","external":true,"refSections":[{"refs":[{"id":"ref-for-clone-a-node-document"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-clone-a-node-document\u2460"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-clone-a-node-document\u2461"},{"id":"ref-for-clone-a-node-document\u2462"}],"title":"8.3. \nNavigation"}],"url":"https://dom.spec.whatwg.org/#clone-a-node-document"}, "ae2a6342": {"dfnID":"ae2a6342","dfnText":"top-level browsing context","external":true,"refSections":[{"refs":[{"id":"ref-for-top-level-browsing-context"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-top-level-browsing-context\u2460"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-top-level-browsing-context\u2461"}],"title":"8.2. \nGroupings of elements"},{"refs":[{"id":"ref-for-top-level-browsing-context\u2462"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-top-level-browsing-context\u2463"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"}],"url":"https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context"}, "at-risk": {"dfnID":"at-risk","dfnText":"at-risk","external":false,"refSections":[{"refs":[{"id":"ref-for-at-risk"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-at-risk\u2460"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"},{"refs":[{"id":"ref-for-at-risk\u2461"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#at-risk"}, "bedd9d42": {"dfnID":"bedd9d42","dfnText":"+","external":true,"refSections":[{"refs":[{"id":"ref-for-mult-one-plus"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://drafts.csswg.org/css-values-4/#mult-one-plus"}, "boundary-box": {"dfnID":"boundary-box","dfnText":"boundary box","external":false,"refSections":[{"refs":[{"id":"ref-for-boundary-box"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-boundary-box\u2460"},{"id":"ref-for-boundary-box\u2461"},{"id":"ref-for-boundary-box\u2462"},{"id":"ref-for-boundary-box\u2463"},{"id":"ref-for-boundary-box\u2464"},{"id":"ref-for-boundary-box\u2465"},{"id":"ref-for-boundary-box\u2466"},{"id":"ref-for-boundary-box\u2467"},{"id":"ref-for-boundary-box\u2468"},{"id":"ref-for-boundary-box\u2460\u24ea"},{"id":"ref-for-boundary-box\u2460\u2460"},{"id":"ref-for-boundary-box\u2460\u2461"},{"id":"ref-for-boundary-box\u2460\u2462"},{"id":"ref-for-boundary-box\u2460\u2463"},{"id":"ref-for-boundary-box\u2460\u2464"},{"id":"ref-for-boundary-box\u2460\u2465"},{"id":"ref-for-boundary-box\u2460\u2466"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#boundary-box"}, "c3bd6e1d": {"dfnID":"c3bd6e1d","dfnText":"box fragment","external":true,"refSections":[{"refs":[{"id":"ref-for-box-fragment"},{"id":"ref-for-box-fragment\u2460"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-box-fragment\u2461"},{"id":"ref-for-box-fragment\u2462"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://drafts.csswg.org/css-break-4/#box-fragment"}, "c51ad875": {"dfnID":"c51ad875","dfnText":"the body element","external":true,"refSections":[{"refs":[{"id":"ref-for-the-body-element-2"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-the-body-element-2\u2460"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-the-body-element-2\u2461"}],"title":"8.3. \nNavigation"}],"url":"https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2"}, "can-be-manually-scrolled": {"dfnID":"can-be-manually-scrolled","dfnText":"can be manually scrolled","external":false,"refSections":[{"refs":[{"id":"ref-for-can-be-manually-scrolled"},{"id":"ref-for-can-be-manually-scrolled\u2460"},{"id":"ref-for-can-be-manually-scrolled\u2461"}],"title":"8.3. \nNavigation"}],"url":"#can-be-manually-scrolled"}, "d345f720": {"dfnID":"d345f720","dfnText":"focus(options)","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-focus"}],"title":"3. \nOverview"},{"refs":[{"id":"ref-for-dom-focus\u2460"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-dom-focus\u2461"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#dom-focus"}, "d462b34f": {"dfnID":"d462b34f","dfnText":"node","external":true,"refSections":[{"refs":[{"id":"ref-for-boundary-point-node"},{"id":"ref-for-boundary-point-node\u2460"}],"title":"8.3. \nNavigation"}],"url":"https://dom.spec.whatwg.org/#boundary-point-node"}, "d95397a7": {"dfnID":"d95397a7","dfnText":"all","external":true,"refSections":[{"refs":[{"id":"ref-for-propdef-all"}],"title":"5.2. \nLow level APIs"}],"url":"https://drafts.csswg.org/css-cascade-5/#propdef-all"}, "dictdef-focusableareasoption": {"dfnID":"dictdef-focusableareasoption","dfnText":"FocusableAreasOption","external":false,"refSections":[{"refs":[{"id":"ref-for-dictdef-focusableareasoption"}],"title":"5.2. \nLow level APIs"}],"url":"#dictdef-focusableareasoption"}, "dictdef-navigationeventinit": {"dfnID":"dictdef-navigationeventinit","dfnText":"NavigationEventInit","external":false,"refSections":[{"refs":[{"id":"ref-for-dictdef-navigationeventinit"},{"id":"ref-for-dictdef-navigationeventinit\u2460"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"#dictdef-navigationeventinit"}, "dictdef-spatialnavigationsearchoptions": {"dfnID":"dictdef-spatialnavigationsearchoptions","dfnText":"SpatialNavigationSearchOptions","external":false,"refSections":[{"refs":[{"id":"ref-for-dictdef-spatialnavigationsearchoptions"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-dictdef-spatialnavigationsearchoptions\u2460"}],"title":"Changes"}],"url":"#dictdef-spatialnavigationsearchoptions"}, "directionally-scroll-an-element": {"dfnID":"directionally-scroll-an-element","dfnText":"directionally scroll an element","external":false,"refSections":[{"refs":[{"id":"ref-for-directionally-scroll-an-element"},{"id":"ref-for-directionally-scroll-an-element\u2460"},{"id":"ref-for-directionally-scroll-an-element\u2461"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-directionally-scroll-an-element\u2462"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#directionally-scroll-an-element"}, "dispatches-navbeforefocus-event": {"dfnID":"dispatches-navbeforefocus-event","dfnText":"dispatches navbeforefocus event","external":false,"refSections":[{"refs":[{"id":"ref-for-dispatches-navbeforefocus-event"},{"id":"ref-for-dispatches-navbeforefocus-event\u2460"}],"title":"8.3. \nNavigation"}],"url":"#dispatches-navbeforefocus-event"}, "dispatches-navnotarget-event": {"dfnID":"dispatches-navnotarget-event","dfnText":"dispatches navnotarget event","external":false,"refSections":[{"refs":[{"id":"ref-for-dispatches-navnotarget-event"}],"title":"8.3. \nNavigation"}],"url":"#dispatches-navnotarget-event"}, "dom-element-focusableareas": {"dfnID":"dom-element-focusableareas","dfnText":"focusableAreas(option)","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-element-focusableareas\u2460"},{"id":"ref-for-dom-element-focusableareas\u2461"},{"id":"ref-for-dom-element-focusableareas\u2462"}],"title":"5.2. \nLow level APIs"}],"url":"#dom-element-focusableareas"}, "dom-element-focusableareas-option-option": {"dfnID":"dom-element-focusableareas-option-option","dfnText":"option","external":false,"refSections":[],"url":"#dom-element-focusableareas-option-option"}, "dom-element-getspatialnavigationcontainer": {"dfnID":"dom-element-getspatialnavigationcontainer","dfnText":"getSpatialNavigationContainer()","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-element-getspatialnavigationcontainer\u2460"},{"id":"ref-for-dom-element-getspatialnavigationcontainer\u2461"},{"id":"ref-for-dom-element-getspatialnavigationcontainer\u2462"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-dom-element-getspatialnavigationcontainer\u2463"}],"title":"Changes"}],"url":"#dom-element-getspatialnavigationcontainer"}, "dom-element-spatialnavigationsearch": {"dfnID":"dom-element-spatialnavigationsearch","dfnText":"spatialNavigationSearch","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-element-spatialnavigationsearch"}],"title":"Changes"}],"url":"#dom-element-spatialnavigationsearch"}, "dom-element-spatialnavigationsearch-dir-options-dir": {"dfnID":"dom-element-spatialnavigationsearch-dir-options-dir","dfnText":"dir","external":false,"refSections":[],"url":"#dom-element-spatialnavigationsearch-dir-options-dir"}, "dom-element-spatialnavigationsearch-dir-options-options": {"dfnID":"dom-element-spatialnavigationsearch-dir-options-options","dfnText":"options","external":false,"refSections":[],"url":"#dom-element-spatialnavigationsearch-dir-options-options"}, "dom-element-spatialnavigationsearch-options": {"dfnID":"dom-element-spatialnavigationsearch-options","dfnText":"spatialNavigationSearch(dir, options)","external":false,"refSections":[],"url":"#dom-element-spatialnavigationsearch-options"}, "dom-focusableareasearchmode-all": {"dfnID":"dom-focusableareasearchmode-all","dfnText":"\"all\"","external":false,"refSections":[],"url":"#dom-focusableareasearchmode-all"}, "dom-focusableareasearchmode-visible": {"dfnID":"dom-focusableareasearchmode-visible","dfnText":"\"visible\"","external":false,"refSections":[],"url":"#dom-focusableareasearchmode-visible"}, "dom-focusableareasoption-mode": {"dfnID":"dom-focusableareasoption-mode","dfnText":"mode","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-focusableareasoption-mode"}],"title":"5.2. \nLow level APIs"}],"url":"#dom-focusableareasoption-mode"}, "dom-navigationevent-dir": {"dfnID":"dom-navigationevent-dir","dfnText":"dir","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-navigationevent-dir"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-dom-navigationevent-dir\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"#dom-navigationevent-dir"}, "dom-navigationevent-navigationevent": {"dfnID":"dom-navigationevent-navigationevent","dfnText":"constructor","external":false,"refSections":[],"url":"#dom-navigationevent-navigationevent"}, "dom-navigationevent-navigationevent-type-eventinitdict-eventinitdict": {"dfnID":"dom-navigationevent-navigationevent-type-eventinitdict-eventinitdict","dfnText":"eventInitDict","external":false,"refSections":[],"url":"#dom-navigationevent-navigationevent-type-eventinitdict-eventinitdict"}, "dom-navigationevent-navigationevent-type-eventinitdict-type": {"dfnID":"dom-navigationevent-navigationevent-type-eventinitdict-type","dfnText":"type","external":false,"refSections":[],"url":"#dom-navigationevent-navigationevent-type-eventinitdict-type"}, "dom-navigationevent-relatedtarget": {"dfnID":"dom-navigationevent-relatedtarget","dfnText":"relatedTarget","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-navigationevent-relatedtarget"},{"id":"ref-for-dom-navigationevent-relatedtarget\u2460"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-dom-navigationevent-relatedtarget\u2461"},{"id":"ref-for-dom-navigationevent-relatedtarget\u2462"}],"title":"6.2.2. \nnavnotarget"}],"url":"#dom-navigationevent-relatedtarget"}, "dom-navigationeventinit-dir": {"dfnID":"dom-navigationeventinit-dir","dfnText":"dir","external":false,"refSections":[],"url":"#dom-navigationeventinit-dir"}, "dom-navigationeventinit-relatedtarget": {"dfnID":"dom-navigationeventinit-relatedtarget","dfnText":"relatedTarget","external":false,"refSections":[],"url":"#dom-navigationeventinit-relatedtarget"}, "dom-spatialnavigationdirection-down": {"dfnID":"dom-spatialnavigationdirection-down","dfnText":"\"down\"","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationdirection-down"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2460"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2461"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2462"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2463"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2464"},{"id":"ref-for-dom-spatialnavigationdirection-down\u2465"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#dom-spatialnavigationdirection-down"}, "dom-spatialnavigationdirection-left": {"dfnID":"dom-spatialnavigationdirection-left","dfnText":"\"left\"","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationdirection-left"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2460"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2461"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2462"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2463"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2464"},{"id":"ref-for-dom-spatialnavigationdirection-left\u2465"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#dom-spatialnavigationdirection-left"}, "dom-spatialnavigationdirection-right": {"dfnID":"dom-spatialnavigationdirection-right","dfnText":"\"right\"","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationdirection-right"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2460"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2461"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2462"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2463"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2464"},{"id":"ref-for-dom-spatialnavigationdirection-right\u2465"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#dom-spatialnavigationdirection-right"}, "dom-spatialnavigationdirection-up": {"dfnID":"dom-spatialnavigationdirection-up","dfnText":"\"up\"","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationdirection-up"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2460"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2461"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2462"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2463"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2464"},{"id":"ref-for-dom-spatialnavigationdirection-up\u2465"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#dom-spatialnavigationdirection-up"}, "dom-spatialnavigationsearchoptions-candidates": {"dfnID":"dom-spatialnavigationsearchoptions-candidates","dfnText":"candidates","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationsearchoptions-candidates"}],"title":"5.2. \nLow level APIs"}],"url":"#dom-spatialnavigationsearchoptions-candidates"}, "dom-spatialnavigationsearchoptions-container": {"dfnID":"dom-spatialnavigationsearchoptions-container","dfnText":"container","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-spatialnavigationsearchoptions-container"}],"title":"5.2. \nLow level APIs"}],"url":"#dom-spatialnavigationsearchoptions-container"}, "dom-window-navigate": {"dfnID":"dom-window-navigate","dfnText":"navigate(dir)","external":false,"refSections":[{"refs":[{"id":"ref-for-dom-window-navigate"},{"id":"ref-for-dom-window-navigate\u2460"}],"title":"5.1. \nTriggering Navigation Programmatically"}],"url":"#dom-window-navigate"}, "dom-window-navigate-dir-dir": {"dfnID":"dom-window-navigate-dir-dir","dfnText":"dir","external":false,"refSections":[],"url":"#dom-window-navigate-dir-dir"}, "e6ae10e4": {"dfnID":"e6ae10e4","dfnText":"sequential focus navigation starting point","external":true,"refSections":[{"refs":[{"id":"ref-for-sequential-focus-navigation-starting-point"}],"title":"8.1. \nGlossary"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-starting-point"}, "e8478f36": {"dfnID":"e8478f36","dfnText":"target","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-event-target"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-dom-event-target\u2460"}],"title":"6.2.2. \nnavnotarget"}],"url":"https://dom.spec.whatwg.org/#dom-event-target"}, "e8907287": {"dfnID":"e8907287","dfnText":"hidden","external":true,"refSections":[{"refs":[{"id":"ref-for-valdef-overflow-hidden"},{"id":"ref-for-valdef-overflow-hidden\u2460"}],"title":"Appendix A. Scroll extensions"}],"url":"https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden"}, "e93b53b9": {"dfnID":"e93b53b9","dfnText":"removed","external":true,"refSections":[{"refs":[{"id":"ref-for-nodes-are-removed"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/infrastructure.html#nodes-are-removed"}, "enumdef-focusableareasearchmode": {"dfnID":"enumdef-focusableareasearchmode","dfnText":"FocusableAreaSearchMode","external":false,"refSections":[{"refs":[{"id":"ref-for-enumdef-focusableareasearchmode"}],"title":"5.2. \nLow level APIs"}],"url":"#enumdef-focusableareasearchmode"}, "enumdef-spatialnavigationdirection": {"dfnID":"enumdef-spatialnavigationdirection","dfnText":"SpatialNavigationDirection","external":false,"refSections":[{"refs":[{"id":"ref-for-enumdef-spatialnavigationdirection"}],"title":"5.1. \nTriggering Navigation Programmatically"},{"refs":[{"id":"ref-for-enumdef-spatialnavigationdirection\u2460"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-enumdef-spatialnavigationdirection\u2461"},{"id":"ref-for-enumdef-spatialnavigationdirection\u2462"}],"title":"6.1. \nInterface NavigationEvent"}],"url":"#enumdef-spatialnavigationdirection"}, "eventdef-navigationevent-navbeforefocus": {"dfnID":"eventdef-navigationevent-navbeforefocus","dfnText":"navbeforefocus","external":false,"refSections":[{"refs":[{"id":"ref-for-eventdef-navigationevent-navbeforefocus"}],"title":"6.2.1. \nnavbeforefocus"}],"url":"#eventdef-navigationevent-navbeforefocus"}, "eventdef-navigationevent-navnotarget": {"dfnID":"eventdef-navigationevent-navnotarget","dfnText":"navnotarget","external":false,"refSections":[{"refs":[{"id":"ref-for-eventdef-navigationevent-navnotarget"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-eventdef-navigationevent-navnotarget\u2460"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#eventdef-navigationevent-navnotarget"}, "f285fdb1": {"dfnID":"f285fdb1","dfnText":"relative positioning","external":true,"refSections":[{"refs":[{"id":"ref-for-x34"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://www.w3.org/TR/CSS2/visuren.html#x34"}, "f8434dee": {"dfnID":"f8434dee","dfnText":"being rendered","external":true,"refSections":[{"refs":[{"id":"ref-for-being-rendered"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/rendering.html#being-rendered"}, "fad8924f": {"dfnID":"fad8924f","dfnText":"focusable area","external":true,"refSections":[{"refs":[{"id":"ref-for-focusable-area"},{"id":"ref-for-focusable-area\u2460"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-focusable-area\u2461"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"}, "faf954d6": {"dfnID":"faf954d6","dfnText":"browsing context","external":true,"refSections":[{"refs":[{"id":"ref-for-browsing-context"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-browsing-context\u2460"}],"title":"8.2. \nGroupings of elements"},{"refs":[{"id":"ref-for-browsing-context\u2461"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"}],"url":"https://html.spec.whatwg.org/multipage/browsers.html#browsing-context"}, "fe07e8b2": {"dfnID":"fe07e8b2","dfnText":"focusing steps","external":true,"refSections":[{"refs":[{"id":"ref-for-focusing-steps"},{"id":"ref-for-focusing-steps\u2460"}],"title":"8.3. \nNavigation"}],"url":"https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps"}, "fefe0433": {"dfnID":"fefe0433","dfnText":"preventDefault()","external":true,"refSections":[{"refs":[{"id":"ref-for-dom-event-preventdefault"}],"title":"3. \nOverview"}],"url":"https://dom.spec.whatwg.org/#dom-event-preventdefault"}, "ffc19957": {"dfnID":"ffc19957","dfnText":"painting order","external":true,"refSections":[{"refs":[{"id":"ref-for-painting-order"},{"id":"ref-for-painting-order\u2460"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"https://drafts.csswg.org/css2/zindex.html#painting-order"}, "find-focusable-areas": {"dfnID":"find-focusable-areas","dfnText":"find focusable areas","external":false,"refSections":[{"refs":[{"id":"ref-for-find-focusable-areas"},{"id":"ref-for-find-focusable-areas\u2460"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-find-focusable-areas\u2461"},{"id":"ref-for-find-focusable-areas\u2462"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-find-focusable-areas\u2463"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#find-focusable-areas"}, "find-the-shortest-distance": {"dfnID":"find-the-shortest-distance","dfnText":"find the shortest distance","external":false,"refSections":[{"refs":[{"id":"ref-for-find-the-shortest-distance"}],"title":"8.4. \nFocus Navigation Heuristics"},{"refs":[{"id":"ref-for-find-the-shortest-distance\u2460"}],"title":"9.3. \nSelecting the navigation algorithm: the spatial-navigation-function property"}],"url":"#find-the-shortest-distance"}, "inside-area": {"dfnID":"inside-area","dfnText":"inside area","external":false,"refSections":[{"refs":[{"id":"ref-for-inside-area"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-inside-area\u2460"},{"id":"ref-for-inside-area\u2461"},{"id":"ref-for-inside-area\u2462"},{"id":"ref-for-inside-area\u2463"},{"id":"ref-for-inside-area\u2464"},{"id":"ref-for-inside-area\u2465"},{"id":"ref-for-inside-area\u2466"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#inside-area"}, "navigation-override": {"dfnID":"navigation-override","dfnText":"navigation-override","external":false,"refSections":[{"refs":[{"id":"ref-for-navigation-override"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-navigation-override\u2460"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-navigation-override\u2461"},{"id":"ref-for-navigation-override\u2462"},{"id":"ref-for-navigation-override\u2463"}],"title":"7. \nThe navigation-override policy-controlled feature"}],"url":"#navigation-override"}, "navigationevent": {"dfnID":"navigationevent","dfnText":"NavigationEvent","external":false,"refSections":[{"refs":[{"id":"ref-for-navigationevent"}],"title":"4. \nTriggering Spatial Navigation"},{"refs":[{"id":"ref-for-navigationevent\u2460"},{"id":"ref-for-navigationevent\u2461"},{"id":"ref-for-navigationevent\u2462"}],"title":"6.1. \nInterface NavigationEvent"},{"refs":[{"id":"ref-for-navigationevent\u2463"},{"id":"ref-for-navigationevent\u2464"},{"id":"ref-for-navigationevent\u2465"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-navigationevent\u2466"},{"id":"ref-for-navigationevent\u2467"},{"id":"ref-for-navigationevent\u2468"}],"title":"6.2.2. \nnavnotarget"}],"url":"#navigationevent"}, "propdef-spatial-navigation-action": {"dfnID":"propdef-spatial-navigation-action","dfnText":"spatial-navigation-action","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-spatial-navigation-action\u2460"},{"id":"ref-for-propdef-spatial-navigation-action\u2461"},{"id":"ref-for-propdef-spatial-navigation-action\u2462"},{"id":"ref-for-propdef-spatial-navigation-action\u2463"},{"id":"ref-for-propdef-spatial-navigation-action\u2464"},{"id":"ref-for-propdef-spatial-navigation-action\u2465"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-propdef-spatial-navigation-action\u2466"},{"id":"ref-for-propdef-spatial-navigation-action\u2467"},{"id":"ref-for-propdef-spatial-navigation-action\u2468"},{"id":"ref-for-propdef-spatial-navigation-action\u2460\u24ea"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#propdef-spatial-navigation-action"}, "propdef-spatial-navigation-contain": {"dfnID":"propdef-spatial-navigation-contain","dfnText":"spatial-navigation-contain","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-spatial-navigation-contain\u2460"}],"title":"3. \nOverview"},{"refs":[{"id":"ref-for-propdef-spatial-navigation-contain\u2461"}],"title":"8.2. \nGroupings of elements"},{"refs":[{"id":"ref-for-propdef-spatial-navigation-contain\u2462"},{"id":"ref-for-propdef-spatial-navigation-contain\u2463"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"}],"url":"#propdef-spatial-navigation-contain"}, "propdef-spatial-navigation-function": {"dfnID":"propdef-spatial-navigation-function","dfnText":"spatial-navigation-function","external":false,"refSections":[{"refs":[{"id":"ref-for-propdef-spatial-navigation-function\u2460"}],"title":"9.3. \nSelecting the navigation algorithm: the spatial-navigation-function property"},{"refs":[{"id":"ref-for-propdef-spatial-navigation-function\u2461"}],"title":"Changes"}],"url":"#propdef-spatial-navigation-function"}, "search-origin": {"dfnID":"search-origin","dfnText":"search origin","external":false,"refSections":[{"refs":[{"id":"ref-for-search-origin"},{"id":"ref-for-search-origin\u2460"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#search-origin"}, "select-the-best-candidate": {"dfnID":"select-the-best-candidate","dfnText":"select the best candidate","external":false,"refSections":[{"refs":[{"id":"ref-for-select-the-best-candidate"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-select-the-best-candidate\u2460"}],"title":"6.2.1. \nnavbeforefocus"},{"refs":[{"id":"ref-for-select-the-best-candidate\u2461"},{"id":"ref-for-select-the-best-candidate\u2462"}],"title":"8.3. \nNavigation"}],"url":"#select-the-best-candidate"}, "set-the-search-origin": {"dfnID":"set-the-search-origin","dfnText":"set the search origin","external":false,"refSections":[{"refs":[{"id":"ref-for-set-the-search-origin"}],"title":"8.3. \nNavigation"}],"url":"#set-the-search-origin"}, "spatial-navigation": {"dfnID":"spatial-navigation","dfnText":"spatial navigation","external":false,"refSections":[{"refs":[{"id":"ref-for-spatial-navigation"},{"id":"ref-for-spatial-navigation\u2460"},{"id":"ref-for-spatial-navigation\u2461"}],"title":"1. \nIntroduction"}],"url":"#spatial-navigation"}, "spatial-navigation-containers": {"dfnID":"spatial-navigation-containers","dfnText":"spatial navigation containers","external":false,"refSections":[{"refs":[{"id":"ref-for-spatial-navigation-containers"},{"id":"ref-for-spatial-navigation-containers\u2460"},{"id":"ref-for-spatial-navigation-containers\u2461"},{"id":"ref-for-spatial-navigation-containers\u2462"},{"id":"ref-for-spatial-navigation-containers\u2463"},{"id":"ref-for-spatial-navigation-containers\u2464"},{"id":"ref-for-spatial-navigation-containers\u2465"},{"id":"ref-for-spatial-navigation-containers\u2466"}],"title":"3. \nOverview"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2467"},{"id":"ref-for-spatial-navigation-containers\u2468"},{"id":"ref-for-spatial-navigation-containers\u2460\u24ea"},{"id":"ref-for-spatial-navigation-containers\u2460\u2460"},{"id":"ref-for-spatial-navigation-containers\u2460\u2461"},{"id":"ref-for-spatial-navigation-containers\u2460\u2462"},{"id":"ref-for-spatial-navigation-containers\u2460\u2463"},{"id":"ref-for-spatial-navigation-containers\u2460\u2464"},{"id":"ref-for-spatial-navigation-containers\u2460\u2465"}],"title":"5.2. \nLow level APIs"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2460\u2466"},{"id":"ref-for-spatial-navigation-containers\u2460\u2467"},{"id":"ref-for-spatial-navigation-containers\u2460\u2468"},{"id":"ref-for-spatial-navigation-containers\u2461\u24ea"},{"id":"ref-for-spatial-navigation-containers\u2461\u2460"},{"id":"ref-for-spatial-navigation-containers\u2461\u2461"},{"id":"ref-for-spatial-navigation-containers\u2461\u2462"}],"title":"6.2.2. \nnavnotarget"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2461\u2463"},{"id":"ref-for-spatial-navigation-containers\u2461\u2464"}],"title":"8.2. \nGroupings of elements"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2461\u2465"},{"id":"ref-for-spatial-navigation-containers\u2461\u2466"},{"id":"ref-for-spatial-navigation-containers\u2461\u2467"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2461\u2468"}],"title":"8.4. \nFocus Navigation Heuristics"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2462\u24ea"},{"id":"ref-for-spatial-navigation-containers\u2462\u2460"},{"id":"ref-for-spatial-navigation-containers\u2462\u2461"}],"title":"9.1. \nCreating additional spatial navigation containers: the spatial-navigation-contain property"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2462\u2462"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2462\u2463"},{"id":"ref-for-spatial-navigation-containers\u2462\u2464"}],"title":"9.3. \nSelecting the navigation algorithm: the spatial-navigation-function property"},{"refs":[{"id":"ref-for-spatial-navigation-containers\u2462\u2465"},{"id":"ref-for-spatial-navigation-containers\u2462\u2466"}],"title":"Changes"}],"url":"#spatial-navigation-containers"}, "spatial-navigation-starting-point": {"dfnID":"spatial-navigation-starting-point","dfnText":"spatial navigation starting point","external":false,"refSections":[{"refs":[{"id":"ref-for-spatial-navigation-starting-point"}],"title":"8.1. \nGlossary"},{"refs":[{"id":"ref-for-spatial-navigation-starting-point\u2460"}],"title":"8.4. \nFocus Navigation Heuristics"}],"url":"#spatial-navigation-starting-point"}, "spatial-navigation-steps": {"dfnID":"spatial-navigation-steps","dfnText":"spatial navigation steps","external":false,"refSections":[{"refs":[{"id":"ref-for-spatial-navigation-steps"},{"id":"ref-for-spatial-navigation-steps\u2460"},{"id":"ref-for-spatial-navigation-steps\u2461"}],"title":"4. \nTriggering Spatial Navigation"},{"refs":[{"id":"ref-for-spatial-navigation-steps\u2462"}],"title":"5.1. \nTriggering Navigation Programmatically"}],"url":"#spatial-navigation-steps"}, "update-the-search-origin": {"dfnID":"update-the-search-origin","dfnText":"update the search origin","external":false,"refSections":[{"refs":[{"id":"ref-for-update-the-search-origin"}],"title":"8.4. \nFocus Navigation Heuristics"},{"refs":[{"id":"ref-for-update-the-search-origin\u2460"}],"title":"Changes"}],"url":"#update-the-search-origin"}, "valdef-spatial-navigation-action-auto": {"dfnID":"valdef-spatial-navigation-action-auto","dfnText":"auto","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-spatial-navigation-action-auto"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-valdef-spatial-navigation-action-auto\u2460"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#valdef-spatial-navigation-action-auto"}, "valdef-spatial-navigation-action-focus": {"dfnID":"valdef-spatial-navigation-action-focus","dfnText":"focus","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-spatial-navigation-action-focus"},{"id":"ref-for-valdef-spatial-navigation-action-focus\u2460"},{"id":"ref-for-valdef-spatial-navigation-action-focus\u2461"},{"id":"ref-for-valdef-spatial-navigation-action-focus\u2462"}],"title":"8.3. \nNavigation"},{"refs":[{"id":"ref-for-valdef-spatial-navigation-action-focus\u2463"},{"id":"ref-for-valdef-spatial-navigation-action-focus\u2464"}],"title":"9.2. \nControlling the interaction with scrolling: the spatial-navigation-action property"}],"url":"#valdef-spatial-navigation-action-focus"}, "valdef-spatial-navigation-action-scroll": {"dfnID":"valdef-spatial-navigation-action-scroll","dfnText":"scroll","external":false,"refSections":[{"refs":[{"id":"ref-for-valdef-spatial-navigation-action-scroll"}],"title":"8.3. \nNavigation"}],"url":"#valdef-spatial-navigation-action-scroll"}, "valdef-spatial-navigation-contain-auto": {"dfnID":"valdef-spatial-navigation-contain-auto","dfnText":"auto","external":false,"refSections":[],"url":"#valdef-spatial-navigation-contain-auto"}, "valdef-spatial-navigation-contain-contain": {"dfnID":"valdef-spatial-navigation-contain-contain","dfnText":"contain","external":false,"refSections":[],"url":"#valdef-spatial-navigation-contain-contain"}, "valdef-spatial-navigation-function-grid": {"dfnID":"valdef-spatial-navigation-function-grid","dfnText":"grid","external":false,"refSections":[],"url":"#valdef-spatial-navigation-function-grid"}, "valdef-spatial-navigation-function-normal": {"dfnID":"valdef-spatial-navigation-function-normal","dfnText":"normal","external":false,"refSections":[],"url":"#valdef-spatial-navigation-function-normal"}, }; 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-ref-hints */ "use strict"; { let refsData = { "#at-risk": {"displayText":"at-risk","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"at-risk","type":"dfn","url":"#at-risk"}, "#boundary-box": {"displayText":"boundary box","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"boundary box","type":"dfn","url":"#boundary-box"}, "#can-be-manually-scrolled": {"displayText":"can be manually scrolled","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"can be manually scrolled","type":"dfn","url":"#can-be-manually-scrolled"}, "#dictdef-focusableareasoption": {"displayText":"FocusableAreasOption","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"FocusableAreasOption","type":"dictionary","url":"#dictdef-focusableareasoption"}, "#dictdef-navigationeventinit": {"displayText":"NavigationEventInit","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"NavigationEventInit","type":"dictionary","url":"#dictdef-navigationeventinit"}, "#dictdef-spatialnavigationsearchoptions": {"displayText":"SpatialNavigationSearchOptions","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"SpatialNavigationSearchOptions","type":"dictionary","url":"#dictdef-spatialnavigationsearchoptions"}, "#directionally-scroll-an-element": {"displayText":"directionally scroll the element","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"directionally scroll the element","type":"dfn","url":"#directionally-scroll-an-element"}, "#dispatches-navbeforefocus-event": {"displayText":"dispatches navbeforefocus event","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"dispatches navbeforefocus event","type":"dfn","url":"#dispatches-navbeforefocus-event"}, "#dispatches-navnotarget-event": {"displayText":"dispatches navnotarget event","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"dispatches navnotarget event","type":"dfn","url":"#dispatches-navnotarget-event"}, "#dom-element-focusableareas": {"displayText":"focusableAreas()","export":true,"for_":["Element"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"focusableAreas()","type":"method","url":"#dom-element-focusableareas"}, "#dom-element-getspatialnavigationcontainer": {"displayText":"getSpatialNavigationContainer()","export":true,"for_":["Element"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"getSpatialNavigationContainer()","type":"method","url":"#dom-element-getspatialnavigationcontainer"}, "#dom-element-spatialnavigationsearch": {"displayText":"spatialNavigationSearch(dir)","export":true,"for_":["Element"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatialNavigationSearch(dir)","type":"method","url":"#dom-element-spatialnavigationsearch"}, "#dom-focusableareasoption-mode": {"displayText":"mode","export":true,"for_":["FocusableAreasOption"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"mode","type":"dict-member","url":"#dom-focusableareasoption-mode"}, "#dom-navigationevent-dir": {"displayText":"dir","export":true,"for_":["NavigationEvent"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"dir","type":"attribute","url":"#dom-navigationevent-dir"}, "#dom-navigationevent-relatedtarget": {"displayText":"relatedTarget","export":true,"for_":["NavigationEvent"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"relatedTarget","type":"attribute","url":"#dom-navigationevent-relatedtarget"}, "#dom-spatialnavigationdirection-down": {"displayText":"\"down\"","export":true,"for_":["SpatialNavigationDirection"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"\"down\"","type":"enum-value","url":"#dom-spatialnavigationdirection-down"}, "#dom-spatialnavigationdirection-left": {"displayText":"\"left\"","export":true,"for_":["SpatialNavigationDirection"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"\"left\"","type":"enum-value","url":"#dom-spatialnavigationdirection-left"}, "#dom-spatialnavigationdirection-right": {"displayText":"\"right\"","export":true,"for_":["SpatialNavigationDirection"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"\"right\"","type":"enum-value","url":"#dom-spatialnavigationdirection-right"}, "#dom-spatialnavigationdirection-up": {"displayText":"\"up\"","export":true,"for_":["SpatialNavigationDirection"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"\"up\"","type":"enum-value","url":"#dom-spatialnavigationdirection-up"}, "#dom-spatialnavigationsearchoptions-candidates": {"displayText":"candidates","export":true,"for_":["SpatialNavigationSearchOptions"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"candidates","type":"dict-member","url":"#dom-spatialnavigationsearchoptions-candidates"}, "#dom-spatialnavigationsearchoptions-container": {"displayText":"container","export":true,"for_":["SpatialNavigationSearchOptions"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"container","type":"dict-member","url":"#dom-spatialnavigationsearchoptions-container"}, "#dom-window-navigate": {"displayText":"navigate(dir)","export":true,"for_":["Window"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"navigate(dir)","type":"method","url":"#dom-window-navigate"}, "#enumdef-focusableareasearchmode": {"displayText":"FocusableAreaSearchMode","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"FocusableAreaSearchMode","type":"enum","url":"#enumdef-focusableareasearchmode"}, "#enumdef-spatialnavigationdirection": {"displayText":"SpatialNavigationDirection","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"SpatialNavigationDirection","type":"enum","url":"#enumdef-spatialnavigationdirection"}, "#eventdef-navigationevent-navbeforefocus": {"displayText":"navbeforefocus","export":true,"for_":["NavigationEvent"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"navbeforefocus","type":"event","url":"#eventdef-navigationevent-navbeforefocus"}, "#eventdef-navigationevent-navnotarget": {"displayText":"navnotarget","export":true,"for_":["NavigationEvent"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"navnotarget","type":"event","url":"#eventdef-navigationevent-navnotarget"}, "#find-focusable-areas": {"displayText":"finding focusable areas","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"finding focusable areas","type":"dfn","url":"#find-focusable-areas"}, "#find-the-shortest-distance": {"displayText":"find the shortest distance","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"find the shortest distance","type":"dfn","url":"#find-the-shortest-distance"}, "#inside-area": {"displayText":"inside area","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"inside area","type":"dfn","url":"#inside-area"}, "#navigation-override": {"displayText":"navigation-override","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"navigation-override","type":"dfn","url":"#navigation-override"}, "#navigationevent": {"displayText":"NavigationEvent","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"NavigationEvent","type":"interface","url":"#navigationevent"}, "#propdef-spatial-navigation-action": {"displayText":"spatial-navigation-action","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial-navigation-action","type":"property","url":"#propdef-spatial-navigation-action"}, "#propdef-spatial-navigation-contain": {"displayText":"spatial-navigation-contain","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial-navigation-contain","type":"property","url":"#propdef-spatial-navigation-contain"}, "#propdef-spatial-navigation-function": {"displayText":"spatial-navigation-function","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial-navigation-function","type":"property","url":"#propdef-spatial-navigation-function"}, "#search-origin": {"displayText":"search origin","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"search origin","type":"dfn","url":"#search-origin"}, "#select-the-best-candidate": {"displayText":"selecting the best candidate","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"selecting the best candidate","type":"dfn","url":"#select-the-best-candidate"}, "#set-the-search-origin": {"displayText":"setting the search origin","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"setting the search origin","type":"dfn","url":"#set-the-search-origin"}, "#spatial-navigation": {"displayText":"spatial navigation","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial navigation","type":"dfn","url":"#spatial-navigation"}, "#spatial-navigation-containers": {"displayText":"spatial navigation containers","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial navigation containers","type":"dfn","url":"#spatial-navigation-containers"}, "#spatial-navigation-starting-point": {"displayText":"spatial navigation starting point","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial navigation starting point","type":"dfn","url":"#spatial-navigation-starting-point"}, "#spatial-navigation-steps": {"displayText":"spatial navigation steps","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"spatial navigation steps","type":"dfn","url":"#spatial-navigation-steps"}, "#update-the-search-origin": {"displayText":"update the search origin","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"update the search origin","type":"dfn","url":"#update-the-search-origin"}, "#valdef-spatial-navigation-action-auto": {"displayText":"auto","export":true,"for_":["spatial-navigation-action"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"auto","type":"value","url":"#valdef-spatial-navigation-action-auto"}, "#valdef-spatial-navigation-action-focus": {"displayText":"focus","export":true,"for_":["spatial-navigation-action"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"focus","type":"value","url":"#valdef-spatial-navigation-action-focus"}, "#valdef-spatial-navigation-action-scroll": {"displayText":"scroll","export":true,"for_":["spatial-navigation-action"],"level":"1","normative":true,"shortname":"css-nav","spec":"css-nav-1","status":"local","text":"scroll","type":"value","url":"#valdef-spatial-navigation-action-scroll"}, "8c63e993_https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex": {"displayText":"tabindex","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"tabindex","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"}, "https://dom.spec.whatwg.org/#boundary-point-node": {"displayText":"node","export":true,"for_":["boundary point"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"node","type":"dfn","url":"https://dom.spec.whatwg.org/#boundary-point-node"}, "https://dom.spec.whatwg.org/#canceled-flag": {"displayText":"canceled flag","export":true,"for_":["Event"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"canceled flag","type":"dfn","url":"https://dom.spec.whatwg.org/#canceled-flag"}, "https://dom.spec.whatwg.org/#clone-a-node-document": {"displayText":"document","export":true,"for_":["clone a node"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"document","type":"dfn","url":"https://dom.spec.whatwg.org/#clone-a-node-document"}, "https://dom.spec.whatwg.org/#concept-node-document": {"displayText":"node document","export":true,"for_":["Node"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"node document","type":"dfn","url":"https://dom.spec.whatwg.org/#concept-node-document"}, "https://dom.spec.whatwg.org/#document-element": {"displayText":"document element","export":true,"for_":[],"level":"","normative":true,"shortname":"dom","spec":"dom","status":"anchor-block","text":"document element","type":"dfn","url":"https://dom.spec.whatwg.org/#document-element"}, "https://dom.spec.whatwg.org/#dom-event-preventdefault": {"displayText":"preventDefault()","export":true,"for_":["Event"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"preventDefault()","type":"method","url":"https://dom.spec.whatwg.org/#dom-event-preventdefault"}, "https://dom.spec.whatwg.org/#dom-event-target": {"displayText":"target","export":true,"for_":["Event"],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"target","type":"attribute","url":"https://dom.spec.whatwg.org/#dom-event-target"}, "https://dom.spec.whatwg.org/#element": {"displayText":"Element","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"Element","type":"interface","url":"https://dom.spec.whatwg.org/#element"}, "https://dom.spec.whatwg.org/#event": {"displayText":"Event","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"Event","type":"interface","url":"https://dom.spec.whatwg.org/#event"}, "https://dom.spec.whatwg.org/#eventtarget": {"displayText":"EventTarget","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"EventTarget","type":"interface","url":"https://dom.spec.whatwg.org/#eventtarget"}, "https://dom.spec.whatwg.org/#node": {"displayText":"Node","export":true,"for_":[],"level":"1","normative":true,"shortname":"dom","spec":"dom","status":"current","text":"Node","type":"interface","url":"https://dom.spec.whatwg.org/#node"}, "https://drafts.csswg.org/css-break-4/#box-fragment": {"displayText":"box fragment","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-break","spec":"css-break-4","status":"current","text":"box fragment","type":"dfn","url":"https://drafts.csswg.org/css-break-4/#box-fragment"}, "https://drafts.csswg.org/css-cascade-5/#propdef-all": {"displayText":"all","export":true,"for_":[],"level":"5","normative":true,"shortname":"css-cascade","spec":"css-cascade-5","status":"current","text":"all","type":"property","url":"https://drafts.csswg.org/css-cascade-5/#propdef-all"}, "https://drafts.csswg.org/css-display-4/#box": {"displayText":"box","export":true,"for_":["CSS"],"level":"4","normative":true,"shortname":"css-display","spec":"css-display-4","status":"current","text":"box","type":"dfn","url":"https://drafts.csswg.org/css-display-4/#box"}, "https://drafts.csswg.org/css-display-4/#principal-box": {"displayText":"principal box","export":true,"for_":[],"level":"4","normative":true,"shortname":"css-display","spec":"css-display-4","status":"current","text":"principal box","type":"dfn","url":"https://drafts.csswg.org/css-display-4/#principal-box"}, "https://drafts.csswg.org/css-overflow-3/#propdef-overflow-x": {"displayText":"overflow-x","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"overflow-x","type":"property","url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow-x"}, "https://drafts.csswg.org/css-overflow-3/#propdef-overflow-y": {"displayText":"overflow-y","export":true,"for_":[],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"overflow-y","type":"property","url":"https://drafts.csswg.org/css-overflow-3/#propdef-overflow-y"}, "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/#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-overflow-3/#valdef-overflow-hidden": {"displayText":"hidden","export":true,"for_":["overflow","overflow-x","overflow-y"],"level":"3","normative":true,"shortname":"css-overflow","spec":"css-overflow-3","status":"current","text":"hidden","type":"value","url":"https://drafts.csswg.org/css-overflow-3/#valdef-overflow-hidden"}, "https://drafts.csswg.org/css-overscroll-behavior-1/#scroll-boundary": {"displayText":"scroll boundary","export":true,"for_":[],"level":"","normative":true,"shortname":"overscroll-behavior","spec":"overscroll-behavior","status":"anchor-block","text":"scroll boundary","type":"dfn","url":"https://drafts.csswg.org/css-overscroll-behavior-1/#scroll-boundary"}, "https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region": {"displayText":"optimal viewing region","export":true,"for_":[],"level":"1","normative":true,"shortname":"css-scroll-snap","spec":"css-scroll-snap-1","status":"current","text":"optimal viewing region","type":"dfn","url":"https://drafts.csswg.org/css-scroll-snap-1/#optimal-viewing-region"}, "https://drafts.csswg.org/css-scroll-snap-1/#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":"current","text":"mandatory","type":"value","url":"https://drafts.csswg.org/css-scroll-snap-1/#valdef-scroll-snap-type-mandatory"}, "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/#mult-one-plus": {"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-one-plus"}, "https://drafts.csswg.org/css2/box.html#x14": {"displayText":"border box","export":true,"for_":[],"level":"","normative":true,"shortname":"css2","spec":"css2","status":"anchor-block","text":"border box","type":"dfn","url":"https://drafts.csswg.org/css2/box.html#x14"}, "https://drafts.csswg.org/css2/zindex.html#painting-order": {"displayText":"painting order","export":true,"for_":[],"level":"","normative":true,"shortname":"css2","spec":"css2","status":"anchor-block","text":"painting order","type":"dfn","url":"https://drafts.csswg.org/css2/zindex.html#painting-order"}, "https://drafts.csswg.org/cssom-view-1/#scroll-an-element": {"displayText":"scroll an element","export":false,"for_":[],"level":"1","normative":true,"shortname":"cssom-view","spec":"cssom-view-1","status":"current","text":"scroll an element","type":"dfn","url":"https://drafts.csswg.org/cssom-view-1/#scroll-an-element"}, "https://html.spec.whatwg.org/multipage/browsers.html#browsing-context": {"displayText":"browsing context","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"browsing context","type":"dfn","url":"https://html.spec.whatwg.org/multipage/browsers.html#browsing-context"}, "https://html.spec.whatwg.org/multipage/browsers.html#concept-origin": {"displayText":"origin","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"origin","type":"dfn","url":"https://html.spec.whatwg.org/multipage/browsers.html#concept-origin"}, "https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document": {"displayText":"active document","export":true,"for_":["navigable"],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"active document","type":"dfn","url":"https://html.spec.whatwg.org/multipage/document-sequences.html#nav-document"}, "https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context": {"displayText":"top-level browsing context","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"top-level browsing context","type":"dfn","url":"https://html.spec.whatwg.org/multipage/document-sequences.html#top-level-browsing-context"}, "https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2": {"displayText":"the body element","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"the body element","type":"dfn","url":"https://html.spec.whatwg.org/multipage/dom.html#the-body-element-2"}, "https://html.spec.whatwg.org/multipage/infrastructure.html#nodes-are-removed": {"displayText":"removed","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"removed","type":"dfn","url":"https://html.spec.whatwg.org/multipage/infrastructure.html#nodes-are-removed"}, "https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex": {"displayText":"tabindex","export":true,"for_":["htmlsvg-global"],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"tabindex","type":"element-attr","url":"https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"}, "https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context": {"displayText":"currently focused area of a top-level browsing context","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"currently focused area of a top-level browsing context","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context"}, "https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor": {"displayText":"DOM anchor","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"dom anchor","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#dom-anchor"}, "https://html.spec.whatwg.org/multipage/interaction.html#dom-focus": {"displayText":"focus(options)","export":true,"for_":["HTMLOrSVGElement"],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"focus(options)","type":"method","url":"https://html.spec.whatwg.org/multipage/interaction.html#dom-focus"}, "https://html.spec.whatwg.org/multipage/interaction.html#expressly-inert": {"displayText":"expressly inert","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"expressly inert","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#expressly-inert"}, "https://html.spec.whatwg.org/multipage/interaction.html#focusable-area": {"displayText":"focusable area","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"focusable area","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#focusable-area"}, "https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps": {"displayText":"focusing steps","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"focusing steps","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#focusing-steps"}, "https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-order": {"displayText":"sequential focus navigation order","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"sequential focus navigation order","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-order"}, "https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-starting-point": {"displayText":"sequential focus navigation starting point","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"sequential focus navigation starting point","type":"dfn","url":"https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-starting-point"}, "https://html.spec.whatwg.org/multipage/nav-history-apis.html#window": {"displayText":"Window","export":true,"for_":[],"level":"1","normative":true,"shortname":"html","spec":"html","status":"current","text":"Window","type":"interface","url":"https://html.spec.whatwg.org/multipage/nav-history-apis.html#window"}, "https://html.spec.whatwg.org/multipage/rendering.html#being-rendered": {"displayText":"being rendered","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"being rendered","type":"dfn","url":"https://html.spec.whatwg.org/multipage/rendering.html#being-rendered"}, "https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled": {"displayText":"actually disabled","export":true,"for_":[],"level":"","normative":true,"shortname":"html","spec":"html","status":"anchor-block","text":"actually disabled","type":"dfn","url":"https://html.spec.whatwg.org/multipage/semantics-other.html#concept-element-disabled"}, "https://infra.spec.whatwg.org/#assert": {"displayText":"assert","export":true,"for_":[],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"assert","type":"dfn","url":"https://infra.spec.whatwg.org/#assert"}, "https://infra.spec.whatwg.org/#list-empty": {"displayText":"empty","export":true,"for_":["list","stack","queue","set"],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"empty","type":"dfn","url":"https://infra.spec.whatwg.org/#list-empty"}, "https://infra.spec.whatwg.org/#list-remove": {"displayText":"remove","export":true,"for_":["list","set"],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"remove","type":"dfn","url":"https://infra.spec.whatwg.org/#list-remove"}, "https://infra.spec.whatwg.org/#ordered-set": {"displayText":"set","export":true,"for_":[],"level":"1","normative":true,"shortname":"infra","spec":"infra","status":"current","text":"set","type":"dfn","url":"https://infra.spec.whatwg.org/#ordered-set"}, "https://w3c.github.io/uievents/#dictdef-uieventinit": {"displayText":"UIEventInit","export":true,"for_":[],"level":"1","normative":true,"shortname":"uievents","spec":"uievents","status":"current","text":"UIEventInit","type":"dictionary","url":"https://w3c.github.io/uievents/#dictdef-uieventinit"}, "https://w3c.github.io/uievents/#dom-keyboardevent-key": {"displayText":"key","export":true,"for_":["KeyboardEvent"],"level":"1","normative":true,"shortname":"uievents","spec":"uievents","status":"current","text":"key","type":"attribute","url":"https://w3c.github.io/uievents/#dom-keyboardevent-key"}, "https://w3c.github.io/uievents/#event-target": {"displayText":"event target","export":true,"for_":[],"level":"","normative":true,"shortname":"ui-events","spec":"ui-events","status":"anchor-block","text":"event target","type":"dfn","url":"https://w3c.github.io/uievents/#event-target"}, "https://w3c.github.io/uievents/#keyboardevent": {"displayText":"KeyboardEvent","export":true,"for_":[],"level":"1","normative":true,"shortname":"uievents","spec":"uievents","status":"current","text":"KeyboardEvent","type":"interface","url":"https://w3c.github.io/uievents/#keyboardevent"}, "https://w3c.github.io/uievents/#keydown": {"displayText":"keydown","export":true,"for_":[],"level":"","normative":true,"shortname":"ui-events","spec":"ui-events","status":"anchor-block","text":"keydown","type":"event","url":"https://w3c.github.io/uievents/#keydown"}, "https://w3c.github.io/uievents/#uievent": {"displayText":"UIEvent","export":true,"for_":[],"level":"1","normative":true,"shortname":"uievents","spec":"uievents","status":"current","text":"UIEvent","type":"interface","url":"https://w3c.github.io/uievents/#uievent"}, "https://w3c.github.io/webappsec-feature-policy/#default-allowlist": {"displayText":"default allowlist","export":true,"for_":[],"level":"","normative":true,"shortname":"feature-policy","spec":"feature-policy","status":"anchor-block","text":"default allowlist","type":"dfn","url":"https://w3c.github.io/webappsec-feature-policy/#default-allowlist"}, "https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature": {"displayText":"policy-controlled feature","export":true,"for_":[],"level":"","normative":true,"shortname":"feature-policy","spec":"feature-policy","status":"anchor-block","text":"policy-controlled feature","type":"dfn","url":"https://w3c.github.io/webappsec-feature-policy/#policy-controlled-feature"}, "https://webidl.spec.whatwg.org/#Exposed": {"displayText":"Exposed","export":true,"for_":[],"level":"1","normative":true,"shortname":"webidl","spec":"webidl","status":"current","text":"Exposed","type":"extended-attribute","url":"https://webidl.spec.whatwg.org/#Exposed"}, "https://webidl.spec.whatwg.org/#idl-DOMString": {"displayText":"DOMString","export":true,"for_":[],"level":"1","normative":true,"shortname":"webidl","spec":"webidl","status":"current","text":"DOMString","type":"interface","url":"https://webidl.spec.whatwg.org/#idl-DOMString"}, "https://webidl.spec.whatwg.org/#idl-sequence": {"displayText":"sequence","export":true,"for_":[],"level":"1","normative":true,"shortname":"webidl","spec":"webidl","status":"current","text":"sequence","type":"dfn","url":"https://webidl.spec.whatwg.org/#idl-sequence"}, "https://webidl.spec.whatwg.org/#idl-undefined": {"displayText":"undefined","export":true,"for_":[],"level":"1","normative":true,"shortname":"webidl","spec":"webidl","status":"current","text":"undefined","type":"interface","url":"https://webidl.spec.whatwg.org/#idl-undefined"}, "https://www.w3.org/TR/CSS2/visuren.html#x34": {"displayText":"relative positioning","export":true,"for_":[],"level":"2","normative":true,"shortname":"css","spec":"css2","status":"snapshot","text":"relative positioning","type":"dfn","url":"https://www.w3.org/TR/CSS2/visuren.html#x34"}, }; 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 refHintKey = link.getAttribute("data-refhint-key"); let key = url; if(refHintKey) { key = refHintKey + "_" + url; } const ref = refsData[key]; 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> <script>/* Boilerplate: script-var-click-highlighting */ "use strict"; { /* Color-choosing design: * Colors are ordered by goodness. * On clicking a var, give it the earliest color with the lowest usage in the algorithm. * On re-clicking, re-use the var's most recent color if that's not currently being used elsewhere. */ const COLOR_COUNT = 7; document.addEventListener("click", e=>{ if(e.target.nodeName == "VAR") { highlightSameAlgoVars(e.target); } }); function highlightSameAlgoVars(v) { // Find the algorithm container. let algoContainer = findAlgoContainer(v); // Not highlighting document-global vars, // too likely to be unrelated. if(algoContainer == null) return; const varName = nameFromVar(v); if(!v.hasAttribute("data-var-color")) { const newColor = chooseHighlightColor(algoContainer, v); for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.setAttribute("data-var-color", newColor); el.setAttribute("data-var-last-color", newColor); } } } else { for(const el of algoContainer.querySelectorAll("var")) { if(nameFromVar(el) == varName) { el.removeAttribute("data-var-color"); } } } } function findAlgoContainer(el) { while(el != document.body) { if(el.hasAttribute("data-algorithm")) return el; el = el.parentNode; } return null; } function nameFromVar(el) { return el.textContent.replace(/(\s|\xa0)+/g, " ").trim(); } function colorCountsFromContainer(container) { const namesFromColor = Array.from({length:COLOR_COUNT}, x=>new Set()); for(let v of container.querySelectorAll("var[data-var-color]")) { let color = +v.getAttribute("data-var-color"); namesFromColor[color].add(nameFromVar(v)); } return namesFromColor.map(x=>x.size); } function leastUsedColor(colors) { // Find the earliest color with the lowest count. let minCount = Infinity; let minColor = null; for(var i = 0; i < colors.length; i++) { if(colors[i] < minCount) { minColor = i; minCount = colors[i]; } } return minColor; } function chooseHighlightColor(container, v) { const colorCounts = colorCountsFromContainer(container); if(v.hasAttribute("data-var-last-color")) { let color = +v.getAttribute("data-var-last-color"); if(colorCounts[color] == 0) return color; } return leastUsedColor(colorCounts); } } </script>