<pre class="metadata">
Title: CSS Overflow Module Level 5
Status: ED
Prepare for TR: no
Work Status: Revising
ED: https://drafts.csswg.org/css-overflow-5/
TR: https://www.w3.org/TR/css-overflow-5/
Shortname: css-overflow
Group: csswg
Level: 5
Editor: Florian Rivoal, On behalf of Bloomberg, http://florian.rivoal.net/, w3cid 43241
Editor: Elika J. Etemad / fantasai, Apple, http://fantasai.inkedblade.net/contact, w3cid 35400
Editor: Robert Flack, Google, flackr@google.com, w3cid 98451
Abstract: This module contains the features of CSS relating to scrollable overflow handling in visual media.
	It builds on the <a href="https://www.w3.org/TR/css-overflow-4/">CSS Overflow Module Level 4</a>,
	adding the ability to generate and associate various scrolling controls
	(markers to indicate scroll progress, buttons to trigger scrolling),
	and adding an appendix containing an experimental exploration
	of <a href="#fragmentation">redirecting overflow by fragmentation</a>.
Include MDN Panels: no
</pre>
<pre class="link-defaults">
spec:css-multicol-1; type:dfn; text:overflow column
spec:css-pseudo-4; type:selector;
	text:::first-letter
	text:::first-line
spec:css-writing-modes-4; type:dfn;
	text:start
	text:end
spec:selectors-4; type:selector;
	text::focus
	text::active
</pre>
<pre class=ignored-specs>
spec: css21
</pre>
<pre class="anchors">
url: https://www.w3.org/TR/CSS21/visudet.html#strut; type: dfn; text: strut;
</pre>
	<style>
		table.source-demo-pair {
			width: 100%;
		}

		.in-cards-demo {
			width: 13em;
			height: 8em;

			padding: 4px;
			border: medium solid blue;
			margin: 6px;

			font: medium/1.3 Times New Roman, Times, serif;
			white-space: nowrap;
		}

		.bouncy-columns-demo {
			width: 6em;
			height: 10em;
			float: left;
			margin: 1em;
			font: medium/1.25 Times New Roman, Times, serif;
			white-space: nowrap;
		}
		.bouncy-columns-demo.one {
			background: aqua; color: black;
			transform: rotate(-3deg);
		}
		.bouncy-columns-demo.two {
			background: yellow; color: black;
			transform: rotate(3deg);
		}

		.article-font-inherit-demo {
			font: 1em/1.25 Times New Roman, Times, serif;
			white-space: nowrap;
		}
		.article-font-inherit-demo.one {
			width: 12em;
			font-size: 1.5em;
			margin-bottom: 1em;
			height: 4em;
		}
		.article-font-inherit-demo.two {
			width: 11em;
			margin-left: 5em;
			margin-right: 2em;
		}

		.dark-columns-demo {
			width: 6em;
			height: 10em;
			float: left;
			margin-right: 1em;
			font: medium/1.25 Times New Roman, Times, serif;
			white-space: nowrap;
		}
		.dark-columns-demo.one {
			background: aqua; color: black;
		}
		.dark-columns-demo.one :link {
			color: blue;
		}
		.dark-columns-demo.one :visited {
			color: purple;
		}
		.dark-columns-demo.two {
			background: navy; color: white;
		}
		.dark-columns-demo.two :link {
			color: aqua;
		}
		.dark-columns-demo.two :visited {
			color: fuchsia;
		}

		.article-max-lines-demo {
			font: 1em/1.25 Times New Roman, Times, serif;
			white-space: nowrap;
		}
		.article-max-lines-demo.one::first-letter {
			font-size: 2em;
			line-height: 0.9;
		}
		.article-max-lines-demo.one {
			font-size: 1.5em;
			width: 16em;
		}
		.article-max-lines-demo.two {
			width: 11.5em;
			float: left; margin-right: 1em;
		}
		.article-max-lines-demo.three {
			width: 11.5em;
			float: left;
		}
		.awesome-table td { padding: 5px; }
		.awesome-table {
			color: #000;
			background: #fff;
			margin: auto;
		}
	</style>

<h2 id="intro">
Introduction</h2>

	This specification extends [[!CSS-OVERFLOW-4]].
	It is currently a diff specification,
	defining only a few new features;
	see [[CSS-OVERFLOW-4]] for the rest of the features related to overflow.

	: [[#scroll-navigation|Scroll navigation controls]]
	::
		This section defines the ability to associate [=scroll markers=]
		with elements in a scroller
		(or generate them automatically as ''::scroll-marker'' [=pseudo-elements=],
		with automatic user behavior and accessible labels),
		which can be activated to scroll to the associated elements
		and reflect the scroller's relative scroll progress
		via the '':target-current'' pseudo-class.

		It also defines ''::scroll-button()'' pseudo-elements,
		which can be activated to cause their associated scroller
		to scroll by a "page" in a given direction.

	: [[#fragmentation|Redirection of Overflow]]
	::
		This section defines a highly experimental, exploratory new model
		for handling overflow by redirecting it into newly-generated [=fragmentation containers=].


<h2 id="overflow-concepts">
Overflow Concepts and Terminology</h2>

Issue: Copy [[css-overflow-3#overflow-concepts|Level 3 content]] when final.

<h3 id="scrolling">Scrolling overflow</h3>

The following is added to the concepts in scrolling overflow:

Every [=scroll container=] maintains a <dfn export>current scroll target</dfn>.
It is initially <code>null</code>,
and is reset to <code>null</code> after any scrolling operations in that [=scroll container=]
initiated by the user,
or any script initiated operations that do not have a target,
or when the target is removed from the document.
Scrolling operations in the [=scroll container=] with a target Element or PseudoElement,
set the [=current scroll target=] to that target Element or PseudoElement.

Issue: Setting the current scroll target should be defined in how to <a>scroll a target into view</a>.

Issue: Use the current scroll target as an <a>anchor priority candidate</a> for scroll anchoring.

<h2 id="scroll-navigation">
Scroll navigation controls</h2>

<h3 id="scroll-markers">
Scroll markers</h3>

A <dfn>scroll marker</dfn> is any element or [=pseudo-element=] with a [=scroll target=].
An element or pseudo-element's <dfn>scroll target</dfn> is the {{Element}} indicated by the [=scroll marker=].
Which elements are [=scroll markers=], and what their [=scroll targets=] are, is host-language defined.
The [[html#the-a-element|HTML &lt;a> element]] and [[svg2#Links|SVG &lt;a> element]]
are [=scroll markers=],
whose [=scroll target=] is the <l spec=html>[=indicated part=]</l>.
While these navigational links can be created today,
there is little feedback to the user regarding the current content being viewed, and
the interaction model does not match the expectations of many modern accessible UI components.

This specification adds a mechanism for creating groups of [=scroll marker=]s,
and for automatically creating ''::scroll-marker'' pseudo-elements.
Within each group, the active marker reflects the current scroll position,
and can be styled to give the user an indication of which section they are in.

Use cases include a table of contents with links to relevant contents,
markers for scrolling carousel pages,
and scrollable tab panels.

<wpt pathprefix="/css/css-pseudo/">
	relative-box-order-of-pseudo-elements.html
</wpt>

Issue: Add images representing these examples.

<h4 id="scroll-marker-grouping">
Scroll marker grouping</h4>

The 'scroll-target-group' property determines whether an element establishes a <dfn>scroll marker group container</dfn> containing [=scroll marker=] elements forming a [=scroll marker group=].

A ''::scroll-marker-group'' [=pseudo-element=] is the [=scroll marker group container=] for its contained ''::scroll-marker'' pseudo-elements, which form a [=scroll marker group=] together.

<h4 id="scroll-target-group">
The 'scroll target group' property</h4>

	<pre class=propdef>
	Name: scroll-target-group
	Value: none | auto
	Initial: none
	Applies to: all elements
	Inherited: no
	Computed value: specified value
	Animation Type: discrete
	Canonical Order: per grammar
	</pre>

	The 'scroll-target-group' property specifies whether the element is a [=scroll marker group container=].

	<dl dfn-type=value dfn-for=scroll-target-group>
		<dt><dfn>none</dfn>
		<dd>
			The element does not establish a [=scroll marker group container=].

		<dt><dfn>auto</dfn>
		<dd>
			The element establishes a [=scroll marker group container=]
			forming a [=scroll marker group=] containing all of the [=scroll marker=] elements
			for which this is the nearest ancestor [=scroll marker group container=].

	</dl>

	<div class='example'>
		The following snippet demonstrates how to automatically highlight the currently visible chapter within a table of contents
		<pre><code highlight="html">
			&lt;!DOCTYPE HTML&gt;
			&lt;title&gt;scroll-target-group example with a table of contents&lt;/title&gt;
			&lt;style&gt;
				ol {
					background-color: gray;
					right: 10px;
					top: 10px;
					position: fixed;
					/* Triggers the browser's algorithm for calculating :target-current. */
					scroll-target-group: auto;
				}

				a:target-current {
					color: red;
				}

				.chapter {
					background: lightgray;
					height: 60vh;
					margin: 10px;
				}
			&lt;/style&gt;
			&lt;ol&gt;
				&lt;li&gt;&lt;a href="#intro"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#ch1"&gt;Chapter 1&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#ch2"&gt;Chapter 2&lt;/a&gt;&lt;/li&gt;
			&lt;/ol&gt;
			&lt;div id="intro" class="chapter"&gt;Introduction content&lt;/div&gt;
			&lt;div id="ch1" class="chapter"&gt;Chapter 1 content&lt;/div&gt;
			&lt;div id="ch2" class="chapter"&gt;Chapter 2 content&lt;/div&gt;
		</code></pre>
	</div>

<h4 id="scroll-marker-group-property">
The 'scroll-marker-group' property</h4>

	<pre class=propdef>
	Name: scroll-marker-group
	Value: none | [ [ before | after ] || [ links | tabs ] ]
	Initial: none
	Applies to: [=scroll containers=]
	Inherited: no
	Computed value: specified keyword(s)
	Animation Type: discrete
	Canonical Order: per grammar
	</pre>

	The 'scroll-marker-group' property specifies whether the [=scroll container=] should have a '::scroll-marker-group' [=pseudo-element=] created,
	and its position relative to the scroll container.

	<dl dfn-type=value dfn-for=scroll-marker-group>
		<dt><dfn>none</dfn>
		<dd>
			The [=scroll container=] does not create a '::scroll-marker-group' pseudo-element.

		<dt><dfn>before</dfn>
		<dd>
			The [=scroll container=] generates a ''::scroll-marker-group'' pseudo-element.
			When originating from the root element,
			the generated pseudo-element's box is the first child of the [=originating element=].
			Otherwise, its box is an immediate preceding sibling to its [=originating element=].

		<dt><dfn>after</dfn>
		<dd>
			The [=scroll container=] generates a ''::scroll-marker-group'' pseudo-element.
			When originating from the root element,
			the generated pseudo-element's box is the last child of the [=originating element=].
			Otherwise, its box is an immediate following sibling to its [=originating element=].

		<dt><dfn>links</dfn>
		<dd>
			The generated ''::scroll-marker-group'' operates in "links" mode,
			functioning like a navigation list.
			This is the default mode if omitted.

		<dt><dfn>tabs</dfn>
		<dd>
			The generated ''::scroll-marker-group'' operates in "tabs" mode,
			functioning like a tablist.

	</dl>

<h4 id="scroll-marker-group-pseudo">The ''::scroll-marker-group'' pseudo-element</h4>

	The <dfn selector>::scroll-marker-group</dfn> [=fully styleable pseudo-element=]
	is generated by a [=scroll container=] element
	having a computed 'scroll-marker-group' property that is not ''scroll-marker-group/none''.
	
	The ''::scroll-marker-group'' generates a box as a <em>sibling</em> of its [=originating element=],
	either immediately preceding (if ''scroll-marker-group: before'')
	or immediately following (if ''scroll-marker-group: after'').

	The following additions are recommended for the default UA stylesheet
	to ensure that the generation of scroll marker [=pseudo-elements=] does not invalidate the layout of the site:

	<pre class="lang-css">
		/* The generation of ::scroll-marker pseudo-elements shouldn't
		 * invalidate layout outside of this pseudo-element. */
		::scroll-marker-group { contain: size !important; }
	</pre>

<h4 id="scroll-marker-pseudo">The ''::scroll-marker'' pseudo-element</h4>

	Similar to ''::before'' and ''::after'', all elements can have a ''::scroll-marker'' pseudo-element,
	which is collected into the ''::scroll-marker-group'' of the nearest [=scroll container=] ancestor,
	and scrolls to the element when activated.

	When the computed 'content' value of a <dfn selector>::scroll-marker</dfn> pseudo-element is not ''content/none''
	and its nearest ancestor [=scroll container=] [=scroll container=] has a computed 'scroll-marker-group' property that is not ''scroll-marker-group/none'',
	the pseudo-element generates a box attached as a child of the ''::scroll-marker-group'' pseudo-element's generated box
	on its nearest ancestor [=scroll container=].
	These boxes are added in the [=tree order=] of their <a>originating element</a>.

	These pseudo-elements are [=fully styleable pseudo-elements=] and have a default style like the [[html#the-a-element|HTML &lt;a> element]].

	These pseudo-elements have an indicated [=scroll target=] of their <a>originating element</a>.

<h4 id="scroll-marker-modes">Scroll Marker Modes</h4>

	A ''::scroll-marker-group'' operates in either <dfn>links</dfn> or <dfn>tabs</dfn> mode based on the 'scroll-marker-group' property value of its [=originating element=]. The chosen mode significantly affects the roles, focus behaviors, and interactions of the associated elements and pseudo-elements (see [[#scroll-marker-activation]]).

	If the mode is [=links=]:

	* The roles of ''::scroll-marker-group'' and ''::scroll-marker'' are `navigation` and `link` respectively.
	* All ''::scroll-marker'' pseudo-elements are tab stops, in order.
	* The roles of the [=originating elements=] are unaffected.

	If the mode is [=tabs=]:

	* The roles of ''::scroll-marker-group'' and ''::scroll-marker'' are `tablist` and `tab` respectively.
	* The ''::scroll-marker-group'' implicitly behaves as a single focusable component, establishing a <a href="https://open-ui.org/components/focusgroup.explainer/">focusgroup</a>.
	* Only the active ''::scroll-marker'' is a tab stop; arrow keys are used to switch between markers. They behave as an element with a <a href="https://html.spec.whatwg.org/multipage/interaction.html#attr-tabindex"><code>tabindex</code></a> of "-1", making them focusable within their ''::scroll-marker-group'' either by arrow key navigation within the group, or via the tab key when currently active (or when no other ''::scroll-marker'' is active and this is the first marker in the group), ensuring the group has a <a href="https://open-ui.org/components/focusgroup.explainer/#guaranteed-tab-stop">guaranteed tab stop</a>.
	* [=Originating elements=] of ''::scroll-marker'' are given an implicit role of `tabpanel`. If the [=originating element=] is a ''::column'' pseudo-element, the `tabpanel` role is given to the [=originating element=] of the ''::column''.
	* The ''::scroll-marker'' pseudo-element is a focus navigation scope owner for its associated [=originating element=]. This means that tab focus moves from the marker to the content. Since only the active marker is a tab stop, contents of the inactive tabpanels are not reached unless the active tab is switched.
	* Content from inactive tabs is also hidden from the accessibility tree, meaning authors do not need to carefully apply `interactivity: inert` to hide the inactive tabpanels.

<h4 id="active-before-after-scroll-markers">
Selecting Scroll Markers: '':target-current'', '':target-before'' and '':target-after'' pseudo-classes</h4>

	Exactly one [=scroll marker=] within each [=scroll marker group=] is determined to be active at a time.
	Such "active" [=scroll markers=] match the <dfn selector>:target-current</dfn> pseudo-class.

	In addition to the <a>:target-current</a> pseudo-class, this specification introduces the <dfn selector>:target-before</dfn> and <dfn selector>:target-after</dfn> pseudo-classes for use with [=scroll marker=] elements.

	These pseudo-classes match [=scroll marker=]s that are, respectively, before or after the [=active marker=] (the one matching <a>:target-current</a>) within the same [=scroll marker group=], as determined by [=flat tree order=]:

	- <b>:target-before</b> matches all [=scroll marker=]s that precede the [=active marker=] in the flat tree order within the group.
	- <b>:target-after</b> matches all [=scroll marker=]s that follow the [=active marker=] in the flat tree order within the group.

<div class='example'>
	The following snippet demonstrates how to style the active scroll marker and scroll markers before and after the currently active one in a table of contents:

	<pre><code highlight="html">
		&lt;!DOCTYPE HTML&gt;
		&lt;title&gt;:target-before and :target-after example&lt;/title&gt;
		&lt;style&gt;
			ol {
				background-color: gray;
				right: 10px;
				top: 10px;
				position: fixed;
				scroll-target-group: auto;
			}
			a:target-before {
				color: #888;
			}
			a:target-current {
				color: red;
				font-weight: bold;
			}
			a:target-after {
				color: #444;
			}
			.chapter {
				background: lightgray;
				height: 60vh;
				margin: 10px;
			}
		&lt;/style&gt;
		&lt;ol&gt;
			&lt;li&gt;&lt;a href="#intro"&gt;Introduction&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#ch1"&gt;Chapter 1&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href="#ch2"&gt;Chapter 2&lt;/a&gt;&lt;/li&gt;
		&lt;/ol&gt;
		&lt;div id="intro" class="chapter"&gt;Introduction content&lt;/div&gt;
		&lt;div id="ch1" class="chapter"&gt;Chapter 1 content&lt;/div&gt;
		&lt;div id="ch2" class="chapter"&gt;Chapter 2 content&lt;/div&gt;
	</code></pre>
</div>

<h4 id="active-scroll-markers-calculation">
Calculating the Active Scroll Marker</h4>

	A scrolling operation might animate towards a particular position
	(e.g. scrollbar arrow clicks, arrow key presses, "behavior: smooth" programmatic scrolls)
	or might directly track a user’s input
	(e.g. touch scrolling, scrollbar dragging).
	In either case, the user agent chooses an 'eventual scroll position' to which the scroller
	will reach. This ensures that the relevant marker is activated immediately.

	This 'eventual scroll position' is used to determine the active marker within each [=scroll marker group=].
	Since markers themselves may represent just the start of the content (e.g. headers), we consider the active marker to be the first one which we are at or beyond the scroll position of.

	Whenever a [=scroll container=] participating in one or more [=scroll marker groups=] is scrolled, or layout changes the eventual scroll position,
	the user agent should determine and update the active marker for each [=scroll marker group=]
	based on the section of content most likely to be of interest given the target scroll position.

	<div algorithm="scroll tracking" class=example>
		Example algorithm to determine the active marker for a given scroll marker <var>group</var>.

		1. Let |scroller| be the nearest common ancestor [=scroll container=] of all of the [=scroll marker=] elements in |group|.
		1. Let |active| be scroller.
		1. While |active| is a [=scroll container=] containing [=scroll target=] elements targeted by |group|:
			1. Let <var>scroller</var> be |active|.
			1. Let <var>targets</var> be the set of the [=scroll target=] elements whose nearest ancestor [=scroll container=] is |scroller|
				and the [=scroll container=] elements which contain [=scroll target=] elements targeted by the [=scroll marker group=] whose nearest ancestor [=scroll container=] is |scroller|.
			1. : If |scroller| has a non-null [=current scroll target=]
				::
					Let active be the first item in |targets| encountered by a reverse tree order walk starting from the [=current scroll target=],
					or the first item in tree order in |targets| if no target is found in the previous walk.

				: Otherwise,
				::

					1. Let <var>primary</var> be the primary scrolling axis, assumed to be the block direction of the container's writing-mode.
					1. Let <var>secondary</var> be the scrolling axis perpendicular to primary.
					1. Let <var>position</var> be the 'eventual scroll position' considering ongoing scrolling operations.
					1. For each <var>axis</var> of |primary|, followed by |secondary|:
						1. 	Let <var>scrollport size</var> be the client size of |scroller| in the dimension |axis|.
						1. 	For each |target| in |targets|, <a>determine the scroll-into-view position</a> of |target| in |axis|, storing this as the associated |target position| of |target|.
						1. 	Let <var>scroll size</var> be the length of the <a>scrollable overflow area</a> of the |scroller| in the dimension |axis|.
						1. 	Let <var>scroll range</var> be <code>|scroll size| - |scrollport size|</code>.
						1.  If |scroll range| is greater than 0, redistribute unreachable target positions:
							1.  Let <var>distribute range</var> be <code>min(1/8 * |scrollport size|, |scroll range| / 2)</code>.
							1.  Let <var>before targets</var> be all |targets| whose associated |target position| is less than <code>|distribute range|</code>.
							1.  Let <var>minimum position</var> be the minimum |target position| of |before targets|.
							1.  Update the associated |target position| of each target in |before targets| to
								<code>(|target position| - |minimum position|) / (|distribute range| - |minimum position|) * |distribute range|</code>.
							1.  Let <var>after targets</var> be all |targets| whose associated |target position| is greater than <code>|scroll range| - |distribute range|</code>.
							1.  Let <var>maximum position</var> be the maximum |target position| of |after targets|.
							1.  Update the associated |target position| of each target in |after targets| to
								<code>(|target position| - (|scroll range| - |distribute range|)) / (|maximum position| - (|scroll range| - |distribute range|)) * |distribute range| + (|scroll range| - |distribute range|)</code>.
						1. 	Let |selected position| be the largest |target position|
							where |target position| is equal to or before |position| in the |axis|,
							or whose nearest smaller |target position| < |position| - |scrollport size| / 2 and whose |target position| < |position| + |scrollport size| / 2.
						1. 	: If there is no such position,
							::
								Set the |selected position| to the first one.

						1. Let |active| be the all of the |targets| whose associated |target position| is |selected position|.
					1. Let |active| be the first item in |active| if it has more than one potential target.

		1. 	Let |selected marker| be the [=scroll marker=] associated with |active|.
			If multiple [=scroll marker=] elements are associated with |active|,
			set |selected marker| to be the marker that is earliest in tree order among them.
		1.  Return |selected marker|
	</div>

	<div algorithm="update active marker">
		Whenever the UA determines that a new marker is the <var>active marker</var> for a [=scroll marker group=] <var>group</var> it must run the following steps:

		1. 	Set the active state of |active marker| to true.
		1.	: If |active marker| was the <a href="https://open-ui.org/components/focusgroup.explainer/#last-focused-memory">last-focused element</a> of the |group|,
				::
					Focus |active marker|
		1. 	Set the <a href="https://open-ui.org/components/focusgroup.explainer/#last-focused-memory">last-focused element</a> of the |group| to |active marker|.
		1. 	Set the active state of all other [=scroll marker=] elements in |group| to false.
	</div>

<h4 id="scroll-marker-activation">Activation behavior</h4>

	<div algorithm="scrollTargetElement activation">
		When a [=scroll marker=] with a non-null [=scroll target=] is activated by explicit invocation or arrow key focus:

		1. Let <var>element</var> be the [=scroll target=] of the control.
		1. Let <var>block</var> be "<code>start</code>".
		1. Let <var>inline</var> be "<code>start</code>".
		1. Let <var>container</var> be the nearest common ancestor <a>scroll container</a> of the scroll markers in the [=scroll marker group=] associated with this [=scroll marker=].
		1. <a lt='scroll a target into view'>Scroll the |element| into view</a> with <var>block</var>, <var>inline</var>, and <var>container</var>.
		1. 	: If the activation was triggered by invocation
			::
				1. <a spec=html>Follow the hyperlink</a> updating the URL.
				1. : If the [=scroll marker group=] is in [=tabs=] mode
					::
						Retain focus on the [=scroll marker=] element.
				1. : If the [=scroll marker group=] is in [=links=] mode
					::
						Set the <a href="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation-starting-point">sequential focus navigation starting point</a> to the [=originating element=], losing focus from the [=scroll marker=].

				Note: In [=tabs=] mode, if the user tabs away, the focus behavior will ensure they tab into the relevant content.
	</div>

<h4 id="scroll-marker-next-focus">Next tab-index-ordered focus</h4>

	When a [=scroll marker=] in [=tabs=] mode is activated,
	the next tabindex-ordered focus navigation will focus the [=scroll target=] if it is focusable,
	otherwise, it will find the next focusable element from the [=scroll target=] 
	as though it were focused.

<h3 id="scroll-buttons">
Scroll Buttons</h3>

The <dfn>::scroll-button( \'*' | <<scroll-button-direction>> )</dfn> pseudo-elements
are generated on [=scroll containers=]
when their computed 'content' value is not ''content/none''.
They generate boxes as if they were immediately preceding <em>siblings</em>
of their [=originating element=],
with content as specified by 'content'.
They exist after their [=originating element's=] ''::scroll-marker-group'' pseudo-element
(when used with ''scroll-marker-group: before'').

Four distinct ''::scroll-button()'' pseudo-elements can exist on a [=scroll container=],
each associated with a [=flow-relative=] direction,
based on their [=originating element's=] [=writing mode=]:
in order, [=block-start=], [=inline-start=], [=inline-end=], and [=block-end=].
The ''::scroll-button()'' pseudo-elements are both focusable and activatable by default,
with their activation behavior being to scroll their [=originating element=]
by one "page" in their associated direction,
similar to pressing PgUp/PgDn keys.
<span class=note>(Usually, this will be about 85% of the [=scrollport=] size.)</span>
Like those keys, this scroll has an [=intended direction and end position=].

Issue: [[CSSOM-VIEW-1]] will grow a "scroll by pages" algorithm,
at which point this can reference that.
See <a href="https://github.com/w3c/csswg-drafts/issues/10914#issuecomment-2380139977">
the resolution on issue #10914</a>.

Issue: Is this the best order for the buttons? 
This does match the usual ordering of logical directions in CSS,
but similar buttons created manually
are usually either ordered with verticals and horizontals each grouped together
(aka block-start/block-end then inline-start/inline-end)
or the verticals "around" the horizontals
(aka block-start/inline-start/inline-end/block-end).

The four ''::scroll-button()'' pseudo-elements are individually selected 
by the selector's argument.
A '*' arguments selects all four ''::scroll-button()''s;
otherwise the selected pseudo-element is determined 
by the <dfn><<scroll-button-direction>></dfn> value:

<dl dfn-type=value dfn-for="<scroll-button-direction>, ::scroll-button()">
	: <dfn>up</dfn>
	: <dfn>down</dfn>
	: <dfn>left</dfn>
	: <dfn>right</dfn>
	:: Selects the ''::scroll-button()'' corresponding to the given physical direction.

	: <dfn>block-start</dfn>
	: <dfn>block-end</dfn>
	: <dfn>inline-start</dfn>
	: <dfn>inline-end</dfn>
	:: Selects the indicated ''::scroll-button()'' pseudo-element.

	: <dfn>prev</dfn>
	::
		Selects either the [=block-start=] or [=inline-start=] ''::scroll-button()'',
		whichever's axis has more "scrollable pages" in the [=originating element=]:
		the [=originating element's=] [=scrollable overflow area|scrollable overflow height=]
		divided by its [=scrollport=] height,
		or the same but for widths.

		If both dimensions are equally sized,
		selects the [=block-start=] ''::scroll-button()''.

		<p class=example>
			For example, say the [=originating element=]
			was 800px wide and 500px tall,
			while its [=scrollable overflow area=]
			was 1200px wide and 1000px tall.
			The horizontal scrolling thus represents 1.5 "pages" (1200/800),
			while the vertical scrolling represents 2 "pages" (1000/500),
			so (assuming the element is in English)
			the ''::scroll-button(prev)'' selector
			would select the [=block-start=] button.

	: <dfn>next</dfn>
	:: Identical to ''::scroll-button()/prev'',
		except it selects the [=block-end=] or [=inline-end=] ''::scroll-button()'' instead.
</dl>

Issue: Do we want to add some multi-button keywords 
to make it easier to style several buttons the same way?
In particular, <css>all</css> is probably useful,
but maybe also <css>horizontal</css>/<css>vertical</css>/<css>block</css>/<css>inline</css>.

The ''::scroll-button()''s are [=fully styleable pseudo-elements=]: there is no restriction on what properties apply to them.
They are styled like buttons, switching between the <a>native appearance</a> and <a>base appearance</a> based on the 'appearance' property value.

The '':disabled'' pseudo-class can apply to ''::scroll-button()''.
It matches a given button
when their [=originating element=]
can't be scrolled in their associated direction.

Issue: The UA stylesheet needs to specify that ''::scroll-button()''s
are styled identically to the <{button}> element,
including disabled styles.

Issue: Should ''::scroll-button()'' use the *full* UA styling of buttons,
aka ''appearance:button''?
Or the non-native rendering, aka ''appearance:none''?
If the former, we'll obviously need to define the interaction with 'appearance'.


<h3 id=overflow-pseudo-focus-behavior>
Focus behavior</h3>

The above features generate several focusable pseudo-elements.
This section defines some of the focus related behaviors.

<h4 id=active-element>
The active element</h4>

When a ''::scroll-button()'' or ''::scroll-marker'' is focused,
the {{DocumentOrShadowRoot/activeElement}}
is the [=scroll container=] the control is associated with.

<h4 id=focus-pseudoclasses>
Focus related pseudo-classes</h4>

When a ''::scroll-button()'' or ''::scroll-marker'' is focused,
none of the focus related pseudo-classes '':focus'', '':focus-visible'' and '':active'' match on the [=scrolling container=].
Instead, '':focus'' and, when relevant '':focus-visible'', match on the focused pseudo-element.
'':active'' matches on the pseudo-element while it is being activated.
'':focus-within'' matches on the [=scroll container=] and all of its ancestors in the [=flat tree=].

When a ''::scroll-marker'' is focused,
'':focus-within'' additionally matches on the ''::scroll-marker-group'' it belongs to.

<h4 id=focus-order>
Focus navigation order</h4>

While these pseudo-elements have a defined position in the element tree,
this isn't an optimal position for focus navigation
(aka "tab order")
for these controls.

Instead,
focus navigation between a [=scroll container=]
and the various pseudo-elements defined in this section
goes in the following order:

1. The ''::scroll-marker-group'' pseudo-elements of the [=scroll container=],
	if it is set to ''scroll-marker-group: before''.

	Note: The individual ''::scroll-marker'' pseudo-elements
	generated by the [=scroll containers=] descendants
	are reparented underneath this ''::scroll-marker-group'',
	and navigated together as a "focus group".

2. The ''::scroll-button()'' pseudo-elements,
	in the order they're defined as existing in.

3. The [=scroll container=] itself,
	and its contents,
	in the normal focus order they would be in.

4. The ''::scroll-marker-group'' pseudo-elements of the [=scroll container=],
	if it is set to ''scroll-marker-group: after''.

<h2 id="scroll-axis-locking">
Scroll Axis Locking</h2>

When handling a scroll resulting from a user's gesture on a page, user
agent's often "lock" the resulting scroll to one axis, i.e. zero out the
deltas in the perpendicular axis.

<p class=example>
	For example, say a user dragged their finger on the screen such that the
	element undeneath the finger would be scrolled by 500px in the y-axis and
	3px in the x-axis. Because the gesture is almost entirely vertical, the user
	agent might	interpret the user's intent to be a perfectly vertical scroll.
	As such, the user agent would ignore the 3px scroll delta and all further
	x-axis deltas for the remainder of the gesture. In this case, the user agent
	has "locked" the scroll to the y-axis.<br><br>
	In many cases, this improves the user experience by avoiding accidental
	drift. However, in cases where an author wishes their element to always be
	diagonally scrollable, e.g. maps or zoomed images, the user would be
	required to always begin their gesture at an angle that would not trigger
	the locking.
</p>

The 'scroll-axis-lock' property lets authors instruct the user
agent not to apply any axis locking when the specified element is scrolled.

<h3 id="scroll-axis-lock">The scroll-axis-lock property</h3>

	<pre class=propdef>
	Name: scroll-axis-lock
	Value: auto | none
	Initial: auto
	Applies to: <a>scroll container</a> elements
	Inherited: no
	Computed value: specified value
	Animation Type: discrete
	Canonical Order: per grammar
	</pre>

	The 'scroll-axis-lock' property specifies whether the user agent may
	lock scrolls on the element to one axis.

	<dl dfn-type=value dfn-for=scroll-axis-lock>
		<dt><dfn>none</dfn>
		<dd>
			The user agent must not lock scrolls on the element to one axis.

		<dt><dfn>auto</dfn>
		<dd>
			The user agent may lock scrolls on the element to one axis.

	</dl>

<h2 id="fragmentation" class=no-num>
Appendix A: Redirection of Overflow</h2>

	<!-- Abstract: This module contains the features of CSS relating to new mechanisms of overflow handling in visual media (e.g., screen or paper).  In interactive media, it describes features that allow the overflow from a fixed size container to be handled by pagination (displaying one page at a time).  It also describes features, applying to all visual media, that allow the contents of an element to be spread across multiple fragments, allowing the contents to flow across multiple regions or to have different styles for different fragments. -->

	ISSUE: This section is highly experimental.
	It documents current attempts
	at extending the capabilities of the 'continue' property
	to solve additional use cases.
	However, it does not currently have consensus.
	It is presented here to encourage discussion,
	but non-experimental implementation is not recommended.

	In CSS Level 1 [[CSS1]], placing more content than would fit
	inside an element with a specified size
	was generally an authoring error.
	Doing so caused the content to extend
	outside the bounds of the element,
	which would likely cause
	that content to overlap with other elements.

	CSS Level 2 [[CSS2]] introduced the 'overflow' property,
	which allows authors to have overflow be handled by scrolling,
	which means it is no longer an authoring error.
	It also allows authors to specify
	that overflow is handled by clipping,
	which makes sense when the author's intent
	is that the content not be shown.
	This was further refined in the CSS Overflow Module Level 3 [[CSS-OVERFLOW-3]].

	However, scrolling is not the only way
	to present large amounts of content,
	and may even not be the optimal way.
	After all, the codex replaced the scroll
	as the common format for large written works
	because of its advantages.

	This specification introduces
	a mechanism for Web pages to specify
	that an element of a page should handle overflow
	through pagination rather than through scrolling.

	This specification also extends the concept of overflow
	in another direction.
	Instead of requiring that authors specify a single area
	into which the content of an element must flow,
	this specification allows authors to specify multiple fragments,
	each with their own dimensions and styles,
	so that the content of the element can flow from one to the next,
	using as many as needed to place the content without overflowing.

	In both of these cases, implementations must
	break the content in the block-progression dimension.
	Implementations must do this is described
	in the CSS Fragmentation Module [[!CSS-BREAK-3]].

<h3 id="channelling-overflow">
Channeling Overflow: the 'continue' property</h3>

	The 'continue' property gives authors the ability
	to request that content that does not fit inside an element
	be fragmented (in the sense of [[!CSS-BREAK-3]]),
	and provides alternatives
	for where the remaining content should continue.

	Notably, this property explains traditional pagination,
	and extends it further.

	<pre class="propdef partial">
		Name: continue
		New Values: overflow | paginate | fragments
		Initial: auto
		Applies to: block containers [[!CSS2]], flex containers [[!CSS3-FLEXBOX]], and grid containers [[!CSS3-GRID-LAYOUT]]
		Inherited: no
		Percentages: N/A
		Computed value: see below
		Animation type: discrete
	</pre>

	Issue: The naming of this property and its values is preliminary.
	This was initially proposed as
	"fragmentation: auto | none | break | clone | page"
	in <a href="https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html">https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html</a>,
	and there is not yet wide agreement as to which naming is better.

	Issue: This property is meant to generalize and replace 'region-fragment'.
	Once it is sufficiently stable in this specification,
	'region-fragment' should be removed from the regions specification in favor of this.

	Note: ''continue: fragments'' replaces "overflow:fragments"
	from earlier versions of this specification,
	while ''continue: paginate'' replaces "overflow: paged-x | paged-y | paged-x-controls | paged-y-controls"

	<dl dfn-for="continue" dfn-type="value">
		<dt>auto
		<dd>''continue/auto'' may only occur as a computed value
		if the element is a <a spec="css-regions">CSS Region</a>
		other than the last one in a <a spec="css-regions">region chain</a>.
		Content that doesn't fit is pushed to the next region of the chain.

		In all other cases, ''continue/auto'' computes to one of the other values.

		Issue: this is different from the definition in [[css-overflow-4#continue]],
		where the specified value is the computed value.
		Which is model better?

		<dt><dfn>overflow</dfn>
		<dd>Content that doesn't fit overflows, according to the 'overflow' property

		<dt><dfn>paginate</dfn>
		<dd>Content that doesn't fit paginates.
		This creates a paginated view inside the element
		similar to the way that 'overflow: scroll' creates a scrollable view.

		See <a href="#paginated-overflow">paginated overflow</a>

		Note: Print is effectively "continue: paginate" on the root.
		<dt><dfn>fragments</dfn>
		<dd>content that doesn't fit causes the element to copy itself and continue laying out.

		See <a href="#fragment-overflow">fragment overflow</a>.
	</dl>

		The computed value of the 'continue' for a given element or [=pseudo-element=] is determined as follow:

	1. On elements or pseudo-elements with <a>layout containment</a> (see [[!CSS-CONTAIN-1]]),
		if the specified value is ''continue/auto'' or ''continue/fragments''
		then the computed value is ''continue/overflow''.
	
	2. Otherwise, if the specified value is ''continue/auto''
		1. On a <a spec="css-regions">CSS Region</a> other than the last one in a <a spec="css-regions">region chain</a>,
			the computed value is ''continue/auto''
		2. On a page
			the computed value is ''continue/paginate''
		3. On a <a>fragment box</a>
			the computed value is ''continue/fragments''
		4. Otherwise, the computed value is ''continue/overflow''

	3. Otherwise, if the specified value is ''continue/fragments''
		1. On a page
			the computed value is ''continue/paginate''
		2. Otherwise, the computed value is the specified value

	4. In all other cases, the computed value is the specified value

	Issue: If we introduce a pseudo-element that can select columns in a multicol,
	we would need to specify that auto computes to auto on it,
	or introduce a new value and have auto compute to that
	(but what would that value compute to on things that aren't columns?).

	Note: For background discussions leading to this property, see these threads:
	<a href="http://lists.w3.org/Archives/Public/www-style/2012May/1197.html">discussion of overflow, overflow-x, overflow-y and overflow-style</a> and
	<a href="https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html">proposal for a fragmentation property</a>

<h3 id="paginated-overflow">
Paginated overflow</h3>

	This section introduces and defines the meaning of the ''continue/paginate'' value of the 'continue' property.

	Issue: Write this section

	Issue: Pages should be possible to style with @page rules. How does that work for nested pages?

	<div class="issue">
		Should traditional pagination (e.g. when printing)
		be expressed through some magic in the computed value of ''continue/auto'',
		or by inserting this in the UA stylesheet:

		<pre><code class="lang-css">
			@media (overflow-block: paged), (overflow-block: optional-paged) {
				:root {
					continue: paginate;
				}
			}
		</code></pre>
	</div>

	Issue: Traditional pagination (e.g. when printing) assumes that
	:root is contained in the page box,
	rather than having the page box be a pseudo-element child of :root.
	Can we work around that using something similar to fragment boxes?
	Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?

	Issue: How does the page box model work when it is a child of a regular css box?

	Issue: The initial proposal in [[CSS3GCPM]] and implementation from Opera
	used 4 values instead of ''continue/paginate'':
	"paged-x | paged-y | paged-x-controls | paged-y-controls".
	Should this property also include these values,
	or are they better handled as separate properties?
	(e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")

	Issue: Ability to display N pages at once
	rather than just one page at once?
	Could this be a value of "pagination-layout", such as:
	"pagination-layout: horizontal 2;"

	Issue: Brad Kemper has proposed a model for combining pagination and
	fragment overflow, which also deals with displaying multiple pages.
	<a href="https://lists.w3.org/Archives/Public/www-style/2015Mar/0241.html">https://lists.w3.org/Archives/Public/www-style/2015Mar/0241.html</a>

	Issue: The current implementation of paginated overflow uses
	the overflow/overflow-x/overflow-y properties
	rather than the overflow-style property as proposed
	in the [[CSS3GCPM]] draft
	(which also matches the [[CSS3-MARQUEE]] proposal).
	or the 'continue' property as described here.

<h3 id="fragment-overflow">
Fragmented Overflow</h3>

	This section introduces and defines the meaning of
	the ''continue/fragments'' value of the 'continue' property.

	When the computed value of 'continue' for an element is ''continue/fragments'',
	and implementations would otherwise have created a box for the element,
	then implementations must create a sequence of <dfn>fragment box</dfn>es
	for that element.
	(It is possible for an element with ''continue: fragments''
	to generate only one <a>fragment box</a>.
	However, if an element's computed 'continue' is not ''continue/fragments'',
	then its box is not a <a>fragment box</a>.)
	Every <a>fragment box</a> is a fragmentation container,
	and any overflow
	that would cause that fragmentation container to fragment
	causes another <a>fragment box</a> created as a next sibling
	of the previous one.
	<span class="issue">Or is it as though it's a next sibling of
	the element?  Need to figure out exactly how this interacts with
	other box-level fixup.</span>
	Additionally, if the <a>fragment box</a> is also
	a multi-column box (as defined in [[!css-multicol-1]]
	<span class="issue">though it defines <i>multi-column container</i></span>)
	any content that would lead to the creation of <a>overflow columns</a> [[!css-multicol-1]]
	instead is flown into an additional fragment box.
	However, fragment boxes may themselves be broken
	(due to fragmentation in a fragmentation context outside of them,
	such as pages, columns, or other fragment boxes);
	such breaking leads to fragments of the same fragment box
	rather than multiple fragment boxes.
	(This matters because fragment boxes may be styled by their index;
	such breaking leads to multiple fragments of a fragment box
	with a single index.
	This design choice is so that
	breaking a fragment box across pages does not break
	the association of indices to particular pieces of content.)
	<span class="issue">Should a forced break that breaks to
	an outer fragmentation context cause a new fragment of a single
	fragment box or a new fragment box?</span>
	<span class="issue">Should we find a term other than
	<a>fragment box</a> here to make this a little less confusing?</span>

	Issue: What if we want to be able to style the pieces of an element
	split within another type of fragmentation context?
	These rules prevent ever using ''::nth-fragment()'' for that,
	despite that the name seems the most logical name for such a feature.

	<div class="example">
		<table class="source-demo-pair">
			<tr>
				<td>
					<pre><code highlight="html">
						&lt;!DOCTYPE HTML&gt;
						&lt;title&gt;Breaking content into
						  equal-sized cards&lt;/title&gt;
						&lt;style&gt;
						  .in-cards {
						    continue: fragments;

						    width: 13em;
						    height: 8em;

						    padding: 4px;
						    border: medium solid blue;
						    margin: 6px;

						    font: medium/1.3 Times New
						      Roman, Times, serif;
						  }
						&lt;/style&gt;
						&lt;div class="in-cards"&gt;
						  In this example, the text in the div
						  is broken into a series of cards.
						  These cards all have the same style.
						  The presence of enough content to
						  overflow one of the cards causes
						  another one to be created.  The second
						  card is created just like it's the
						  next sibling of the first.
						&lt;/div&gt;
					</code></pre>
				<td>
					<div class="in-cards-demo">
						In this example, the text in the<br>div is broken into a series of<br>cards.  These cards all have the<br>same style. The presence of<br>enough content to overflow<br>one of the cards causes another
					</div>
					<div class="in-cards-demo">
						one to be created.  The second<br>card is created just like it's the<br>next sibling of the first.
					</div>
		</table>
	</div>

	<div class="example">
		Authors may wish to style the opening lines of an element
		with different styles
		by putting those opening lines in a separate fragment.
		However, since it may be difficult to predict the exact height
		occupied by those lines
		in order to restrict the first fragment to that height,
		it is more convenient to use the 'max-lines' property,
		which forces a fragment to break
		after a specified number of lines.
		This forces a break after the given number of lines
		contained within the element or its descendants,
		as long as those lines are in the same block formatting context.

		<table class="source-demo-pair">
			<tr>
				<td>
					<pre><code highlight="html">
						&lt;!DOCTYPE HTML&gt;
						&lt;style&gt;
						  .article {
						    continue: fragments;
						  }
						  .article::first-letter {
						    font-size: 2em;
						    line-height: 0.9;
						  }
						  .article::nth-fragment(1) {
						    font-size: 1.5em;
						    max-lines: 3;
						  }
						  .article::nth-fragment(2) {
						    column-count: 2;
						  }
						&lt;/style&gt;
						&lt;div class="article"&gt;
						  <i>...</i>
						&lt;/div&gt;</code>
					</pre>
				<td>
					<div class="article-max-lines-demo one">The max-lines property allows<br>authors to use a larger font for the first<br>few lines of an article.  Without the</div>
					<div class="article-max-lines-demo two">max-lines property, authors<br>might have to use the<br>'height' property instead, but<br>that would leave a slight gap<br>if the author miscalculated<br>how much height a given<br>number of lines would<br>occupy (which might be</div>
					<div class="article-max-lines-demo three">particularly hard if the author<br>didn't know what text would<br>be filling the space, exactly<br>what font would be used, or<br>exactly which platform's font<br>rendering would be used to<br>display the font).</div>
		</table>
	</div>

	Issue: We should specify that ''continue: fragments'' does not apply
	to at least some table parts,
	and perhaps other elements as well.
	We need to determine exactly which ones.

	Issue: This specification needs to say which type of
	fragmentation context is created
	so that it's clear which values of the 'break-*' properties
	cause breaks within this context.
	We probably want ''break-*: region'' to apply.

	Issue: This specification needs a processing model
	that will apply in cases where the layout containing the
	fragments has characteristics that use the intrinsic size of the fragments
	to change the amount of space available for them,
	such as [[CSS3-GRID-LAYOUT]].
	There has already been some work on such a processing model
	in [[CSS-REGIONS-1]],
	and the work done on a model there,
	and the editors of that specification,
	should inform what happens in this specification.

<h3 id="fragment-styling">Fragment styling</h3>

<h4 id="fragment-pseudo-element">
The ''::nth-fragment()'' pseudo-element</h4>

	The <dfn selector>::nth-fragment()</dfn> [=pseudo-element=]
	is a pseudo-element
	that describes some of the <a>fragment box</a>es generated by an element.
	The argument to the pseudo-element takes the same syntax
	as the argument to the :nth-child() pseudo-class
	defined in [[!SELECT]], and has the same meaning
	except that the number is relative to
	<a>fragment box</a>es generated by the element
	instead of siblings of the element.

	Note: Selectors that allow addressing fragments
	by counting from the end rather than the start
	are intentionally not provided.
	Such selectors would interfere with determining
	the number of fragments.

	Issue: Depending on future discussions,
	this ''::nth-fragment(<var>an+b</var>)'' syntax
	may be replaced with
	the new ''::fragment:nth(<var>an+b</var>)'' syntax.

<h4 id="style-of-fragments">
Styling of fragments</h4>

	Issue: Should this apply to continue:fragments only,
	or also to continue:paginate?
	(If it applies,
	then stricter property restrictions would be needed
	for continue:paginate.)

	In the absence of rules with ''::nth-fragment()'' [=pseudo-elements=],
	the computed style for each <a>fragment box</a>
	is the computed style for the element
	for which the <a>fragment box</a> was created.
	However, the style for a <a>fragment box</a> is also influenced
	by rules whose selector's [=selector/subject=]
	has an ''::nth-fragment()'' pseudo-element,
	if the 1-based number of the <a>fragment box</a> matches
	that ''::nth-fragment()'' pseudo-element
	and the selector (excluding the ''::nth-fragment()'' pseudo-element)
	matches the element generating the fragments.

	When determining the style of the <a>fragment box</a>,
	these rules that match the fragment pseudo-element
	cascade together with the rules that match the element,
	with the fragment pseudo-element adding the specificity
	of a pseudo-class to the specificity calculation.
	<span class="issue">Does this need to be specified in
	the cascading module as well?</span>

	<div class="example">
		<table class="source-demo-pair">
			<tr>
				<td>
					<pre><code highlight="html">
						&lt;!DOCTYPE HTML&gt;
						&lt;style&gt;
						  .bouncy-columns {
						    continue: fragments;
						    width: 6em;
						    height: 10em;
						    float: left;
						    margin: 1em;
						    font: medium/1.25 Times New
						      Roman, Times, serif;
						  }
						  .bouncy-columns::nth-fragment(1) {
						    background: aqua; color: black;
						    transform: rotate(-3deg);
						  }
						  .bouncy-columns::nth-fragment(2) {
						    background: yellow; color: black;
						    transform: rotate(3deg);
						  }
						&lt;/style&gt;
						&lt;div class="bouncy-columns"&gt;
						  <i>...</i>
						&lt;/div&gt;
					</code></pre>
				<td>
					<div class="bouncy-columns-demo one">In this<br>example, the<br>text in the div<br>is broken into<br>a series of<br>columns.  The<br>author<br>probably</div>
					<div class="bouncy-columns-demo two">intended the<br>text to fill two<br>columns.  But<br>if it happens to<br>fill three<br>columns, the<br>third column is<br>still created.  It</div>
					<div class="bouncy-columns-demo">just doesn't<br>have any<br>fragment-specific<br>styling because<br>the author<br>didn't give it<br>any.</div>
		</table>
	</div>

	Styling an ''::nth-fragment()'' [=pseudo-element=] with the 'continue'
	property does take effect;
	if a <a>fragment box</a> has a
	computed value of 'continue' other than ''fragments''
	then that fragment box is the last fragment.
	However, overriding 'continue' on the first fragment
	does not cause the <a>fragment box</a> not to exist;
	whether there are fragment boxes at all is determined by
	the computed value of overflow for the element.

	Styling an ''::nth-fragment()'' pseudo-element with the 'content'
	property has no effect;
	the computed value of 'content' for the fragment box
	remains the same as the computed value of content for the element.

	Specifying ''display: none'' for a <a>fragment box</a> causes
	the fragment box with that index not to be generated.
	However, in terms of the indices
	used for matching ''::nth-fragment()'' pseudo-elements
	of later fragment boxes,
	it still counts as though it was generated.
	However, since it is not generated, it does not contain any content.

	Specifying other values of 'display', 'position',
	or 'float' is permitted, but is not allowed to change
	the <a>inner display type</a>.
	(Since 'continue' only
	applies to block containers, flex containers, and grid containers).
	<span class="issue">Need to specify exactly how this works</span>

	To match the model for other [=pseudo-elements=]
	where the pseudo-elements live inside their corresponding element,
	declarations in ''::nth-fragment()'' pseudo-elements override
	declarations in rules without the pseudo-element.
	The relative priority within such declarations is determined
	by normal cascading order (see [[!CSS2]]).

	Styles specified on ''::nth-fragment()'' pseudo-elements
	do affect inheritance to content within the <a>fragment box</a>.
	In other words, the content within the <a>fragment box</a> must
	inherit from the fragment box's style (i.e., the pseudo-element style)
	rather than directly from the element.
	This means that elements split between fragment boxes may
	have different styles for different parts of the element.

	Issue: This inheritance rule allows specifying styles indirectly
	(by using explicit ''inherit'' or using default inheritance
	on properties that don't apply to ''::first-letter'')
	that can't be specified directly
	(based on the rules in the next section).
	This is a problem.
	The restrictions that apply to styling inside fragments
	should also apply to inheritance from fragments.

	<div class="example">
		<table class="source-demo-pair">
			<tr>
				<td>
					<pre><code highlight="html">
					&lt;!DOCTYPE HTML&gt;
					&lt;style&gt;
					  .article {
					    continue: fragments;
					  }
					  .article::nth-fragment(1) {
					    font-size: 1.5em;
					    margin-bottom: 1em;
					    height: 4em;
					  }
					  .article::nth-fragment(2) {
					    margin-left: 5em;
					    margin-right: 2em;
					  }
					&lt;/style&gt;
					&lt;div class="article"&gt;
					  The &lt;code&gt;font-size&lt;/code&gt; property<i>...</i>
					&lt;/div&gt;
					</code></pre>
				<td>
					<div class="article-font-inherit-demo one">The <code>font-size</code> property<br>specified on the fragment<br>is inherited into the</div>
					<div class="article-font-inherit-demo two">descendants of the fragment.<br>This means that inherited<br>properties can be used<br>reliably on a fragment, as in<br>this example.</div>
		</table>
	</div>

<h4 id="style-in-fragments">Styling inside fragments</h4>

		Issue: Should this apply to continue:fragments only,
		or also to continue:paginate?

		The ''::nth-fragment()'' [=pseudo-element=]
		can also be used to style
		content inside of a <a>fragment box</a>.
		Unlike the ''::first-line'' and ''::first-letter'' pseudo-elements,
		the ''::nth-fragment()'' pseudo-element can be applied
		to parts of the selector other than the subject:
		in particular, it can match ancestors of the subject.
		However, the only CSS properties applied
		by rules with such selectors
		are those that apply
		to the ''::first-letter'' pseudo-element.

		To be more precise,
		when a rule's selector has ''::nth-fragment()'' pseudo-elements
		attached to parts of the selector other than the subject,
		the declarations in that rule apply to
		a fragment (or pseudo-element thereof) when:

		1. the declarations are for properties that apply to the
			''::first-letter'' pseudo-element,

		2. the declarations would apply to
			that fragment (or pseudo-element thereof)
			had those ''::nth-fragment()'' pseudo-elements been removed,
			with a particular association between
			each sequence of simple selectors and the element it matched,
			and

		3. for each removed ''::nth-fragment()'' pseudo-element,
			the fragment lives within a <a>fragment box</a>
			of the element associated in that association
			with the selector that the pseudo-element was attached to,
			and whose index matches the pseudo-element.

	<div class="example">
		<table class="source-demo-pair">
			<tr>
				<td>
					<pre><code highlight="html">
						&lt;!DOCTYPE HTML&gt;
						&lt;style&gt;
						  .dark-columns {
						    continue: fragments;
						    width: 6em;
						    height: 10em;
						    float: left;
						    margin-right: 1em;
						    font: medium/1.25 Times New
						      Roman, Times, serif;
						  }
						  .dark-columns::nth-fragment(1) {
						    background: aqua; color: black;
						  }
						  .dark-columns::nth-fragment(1) :link {
						    color: blue;
						  }
						  .dark-columns::nth-fragment(1) :visited {
						    color: purple;
						  }
						  .dark-columns::nth-fragment(2) {
						    background: navy; color: white;
						  }
						  .dark-columns::nth-fragment(2) :link {
						    color: aqua;
						  }
						  .dark-columns::nth-fragment(2) :visited {
						    color: fuchsia;
						  }
						&lt;/style&gt;
						&lt;div class="dark-columns"&gt;
						  <i>...</i>
						&lt;/div&gt;
					</code></pre>
				<td>
					<div class="dark-columns-demo one">In this<br><a href="http://en.wiktionary.org/wiki/example">example</a>, the<br>text flows<br>from one<br>light-colored<br>fragment into<br>another<br>dark-colored</div>
					<div class="dark-columns-demo two">fragment.  We<br>therefore want<br>different styles<br>for <a href="http://www.w3.org/Provider/Style/IntoContext.html">hyperlinks</a><br>in the different<br>fragments.</div>
		</table>
	</div>

<h2 id=privacy class=no-num>
Appendix C: Privacy Considerations</h2>

This specification introduces no new privacy considerations.

<h2 id=security class=no-num>
Appendix D: Security Considerations</h2>

This specification introduces no new security considerations.

<h2 id="changes-l4" class=no-num>
Changes Since Level 4</h2>

	ISSUE: TBD

<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>

	<p>
		Thanks especially to the feedback from
		Rossen Atanassov,
		Bert Bos,
		Tantek Çelik,
		John Daggett,
		fantasai,
		Daniel Glazman,
		Vincent Hardy,
		H&aring;kon Wium Lie,
		Peter Linss,
		Robert O'Callahan,
		Florian Rivoal,
		Alan Stearns,
		Steve Zilles,
		and all the rest of the
		<a href="http://lists.w3.org/Archives/Public/www-style/">www-style</a> community.
