Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-initial-target — initial scrolling target

The scroll-initial-target property identifies an element that determines its nearest scroll container’s initial scroll position.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

scroll-initial-target: none | nearest;

Set scroll-initial-target on the target element, not the container. none is the initial value; nearest nominates the element as a target for its nearest scroll container. The property is neither inherited nor animated.

With multiple candidates, the browser should choose the first in tree order. It calculates the position using block: start and inline: nearest; the property’s nearest identifies the container, not block alignment. The mechanism does not require scroll-snap-type.

This is a draft specification feature, not a support guarantee. Test the example in your target browser.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Initial scroll target</title>
<style>
  .scroller {
    width: 240px;
    height: 100px;
    overflow: auto;
    writing-mode: horizontal-tb;
    direction: ltr;
  }
  .item {
    height: 100px;
    background: #eee;
  }
  .target {
    scroll-initial-target: nearest;
    background: #cfc;
  }
</style>
<div class="scroller" tabindex="0" aria-label="Numbered items">
  <div class="item">1</div>
  <div class="item target">2</div>
  <div class="item">3</div>
</div>
</html>

Result

Expected with support on a fresh load: item 2 is visible and .scroller.scrollTop is 100.

On a fresh load in a browser that supports this property, item 2 is expected to be visible and `.scroller.scrollTop` is expected to be `100`.

Sources