CKTIS / CSS
direction — the inline base direction
The direction property sets the base direction of inline content; it does not simply reverse the characters.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
direction: ltr | rtl;direction accepts ltr or rtl; its initial value is ltr, and it is inherited. It sets the inline base direction, also influencing default alignment and table-column ordering.
Character ordering also depends on the Unicode bidirectional algorithm and unicode-bidi. Setting rtl alone does not reverse Latin letters. On an inline box with unicode-bidi: normal, the property does not affect bidi reordering. In contrast, writing-mode determines block flow direction.
In HTML documents, use the dir attribute rather than CSS to express content direction: it retains its meaning without stylesheets. The following example deliberately demonstrates the CSS mechanism.
Examples
<!doctype html>
<meta charset="utf-8">
<title>direction demo</title>
<style>
.sample {
direction: rtl;
writing-mode: horizontal-tb;
width: 240px;
border: 1px solid;
}
</style>
<div class="sample" id="sample">ABC 123</div>
<pre id="result"></pre>
<script>
const sample = document.getElementById('sample');
document.getElementById('result').textContent =
getComputedStyle(sample).direction;
</script>Result
rtl
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.