Favorites

CSS <axis> Data Type

<axis>
CSS Data TypeThis data type is supported by all modern browsers.
Updated 21st November 2026

The <axis> data type is the direction of a scroll timeline: block, inline, x or y. It is used by scroll-driven animations.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The <axis> CSS data type represents the direction of a scroll axis. It is used by scroll-driven animations to decide which scroll direction of a scroll container drives the progress of a timeline. The type accepts two logical keywords, block and inline, and two physical keywords, x and y. You will meet it in properties such as scroll-timeline-axis and view-timeline-axis, and as an argument of the scroll() and view() functions used with animation-timeline.

The logical keywords follow the element's writing-mode. In a normal horizontal writing mode, block is the vertical direction (the way paragraphs stack) and inline is the horizontal direction (the way text runs). If the writing mode is vertical, these swap, so a timeline using block keeps tracking the direction in which content flows. The physical keywords ignore the writing mode: x is always horizontal and y is always vertical. When no axis is given, block is the default.

Choosing the correct axis matters most for horizontally scrolling components such as carousels, image strips and timelines, where the scroll happens along the inline (or x) direction rather than the default block direction.

Examples:

/* Page progress bar driven by vertical scrolling of the root */
.progress {
  animation: grow linear;
  animation-timeline: scroll(root block);
}

/* A named timeline that tracks horizontal scrolling */
.carousel {
  overflow-x: auto;
  scroll-timeline-name: --carousel;
  scroll-timeline-axis: inline; /* or x */
}

/* An element animating as it crosses a horizontal scroller */
.slide {
  animation: fade-in linear both;
  animation-timeline: view(x);
}

@keyframes grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

Because <axis> only selects a direction, it is usually combined with other scroll-timeline settings such as the scroller (nearest, root or self) and the animation range.

Syntax

<axis> = block | inline | x | y

Values

  • blockThe block axis of the scroll container, which is the direction in which blocks of content are stacked. In horizontal writing modes this is the vertical axis. This is the default value.
  • inlineThe inline axis of the scroll container, which is the direction in which text runs. In horizontal writing modes this is the horizontal axis.
  • xThe horizontal axis of the scroll container, regardless of writing mode.
  • yThe vertical axis of the scroll container, regardless of writing mode.

Example

<div class="wrap">
<h1>CSS &lt;axis&gt; example</h1>
<div class="progress"></div>
<div class="strip">
<div class="card">1</div>
<div class="card">2</div>
<div class="card">3</div>
<div class="card">4</div>
<div class="card">5</div>
<div class="card">6</div>
<div class="card">7</div>
</div>
<p class="note">Scroll the strip sideways: the bar follows scroll-timeline-axis: x.</p>
</div>
/* Demonstrates the  data type with scroll-driven animations */
* { box-sizing: border-box; }

body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f5f7fb;
  color: #102a43;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  /* lets the progress bar see the named timeline of its sibling */
  timeline-scope: --strip;
}

h1 {
  font-size: 20px;
  margin: 0 0 12px;
}

.progress {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  transform-origin: left center;
  transform: scaleX(0);
  margin-bottom: 12px;
  animation: grow linear both;
  animation-timeline: --strip;
}

.strip {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 16px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
  /* track the horizontal (x) axis instead of the default block axis */
  scroll-timeline-name: --strip;
  scroll-timeline-axis: x;
}

.card {
  flex: 0 0 180px;
  height: 120px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: #2563eb;
}

.card:nth-child(even) { background: #0891b2; }

.note {
  font-size: 13px;
  color: #486581;
}

@keyframes grow {
  to { transform: scaleX(1); }
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS axis data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.