Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `inset-inline-start`

`inset-inline-start` sets the logical start inline-axis inset of a positioned box. In horizontal writing it normally maps to a left or right physical offset according to text direction.

Version: CSS modules; captured CSSWG editor index includes draft and obsolete features requiring review

Syntax

<'top'>

inset-inline-start sets the logical start inline-axis inset of a positioned box. In horizontal writing it normally maps to a left or right physical offset according to text direction.

The example puts an absolutely positioned child in a 100 px container, applies a 12 px inset, and reports the child coordinates relative to that container.

The initial value is auto; the property is not inherited. In addition, the percentage basis is defined by the module, and the module defines interpolation behavior.

It affects only a positioned element. Mapping to top, right, bottom, or left depends on writing-mode, direction, and text-orientation; a percentage uses the containing block logical width.

Examples

<!doctype html>
<html lang="en"><meta charset="utf-8"><title>CKTIS CSS reference example</title>
<body><div class="probe">probe</div><pre id="result"></pre><script>
document.body.innerHTML = '<div id="container"><div id="child"></div></div><pre id="result"></pre>';
const container = document.querySelector("#container");
const child = document.querySelector("#child");
container.style.cssText = "position:relative;width:100px;height:40px";
child.style.cssText = "position:absolute;width:20px;height:20px";
child.style.setProperty("inset-inline-start", "12px");
const outer = container.getBoundingClientRect();
const inner = child.getBoundingClientRect();
const x = Math.round(inner.left - outer.left);
const y = Math.round(inner.top - outer.top);
const computed = getComputedStyle(child).getPropertyValue("inset-inline-start").trim();
document.querySelector("#result").textContent = "computed=" + computed + "; child=(" + x + "," + y + ")";
</script></body></html>

Result

computed=12px; child=(12,0)

The example was executed locally in an isolated, network-free Chrome session; the result comes from the browser CSS API.

Sources