The direction property sets the base inline direction for text, table and grid columns, and horizontal overflow. Use ltr for left-to-right languages and rtl for right-to-left languages such as Arabic or Hebrew.
It is inherited. Prefer the HTML dir attribute for document or section language direction. Use CSS direction when you need a component-level switch or cannot change markup.
Baseline · Widely available.
Not deprecated. MDN warns authors to prefer HTML dir over CSS direction for page language direction when possible.
Warning
Where possible, prefer the HTML dir attribute over CSS direction for language direction. Do not force English UI into rtl only to flip layout — use logical properties instead.
Syntax
CSS Syntax
syntax.css
direction:ltr | rtl | initial | inherit;
Only two direction keywords exist. Global keywords such as initial and inherit also apply.
Values
Property Values
Value
Description
Try it
ltr
Left to right. Initial value for most Western languages
Mark the language.lang="ar" helps browsers and assistive tech.
Set direction: rtl. The paragraph flows right to left.
Match script and direction. Arabic reads naturally in RTL.
Prefer dir="rtl" on the element in production HTML when you can.
Edge Cases & Pitfalls
If direction looks wrong, check these first.
html
Prefer HTML dir for language direction
MDN recommends the dir attribute for documents and major sections. CSS direction is better as a local layout tool.
inline
Inline elements need unicode-bidi
For direction to affect inline-level elements, set unicode-bidi to embed or override.
logical
Physical left/right break in RTL
margin-left stays on the physical left. Prefer margin-inline-start so spacing follows direction.
all
direction is excluded from all
direction and unicode-bidi are not reset by the all shorthand. Reset them explicitly when needed.
tables
Table columns do not inherit into cells via CSS
Unlike HTML dir on a column, CSS inheritance follows the tree. Cells inherit from rows/ancestors, not from column elements.
Compatibility
Browser Support
direction is a browser CSS property for text and layout flow. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
direction
Supported in all modern browsers and older engines. Prefer HTML dir for document language direction.
99%Browser support
Google ChromeAll modern versions
Full support
Mozilla FirefoxAll modern versions
Full support
Apple SafariAll modern versions
Full support
Microsoft EdgeAll modern versions
Full support
OperaAll modern versions
Full support
Samsung InternetSupported
Full support
Internet ExplorerSupported
Full support
directionWidely supported
Bottom line: Safe to use for LTR/RTL layout demos. Prefer HTML dir for page language. It is not a runtime API.
Remember
Key Takeaways
Role: set base inline direction for text and layout.
Values:ltr (default) or rtl. Inherited.
Prefer HTML dir for document and section language direction.
Inline caveat: pair with unicode-bidi on inline elements.
One line: use direction for local LTR/RTL flow — and HTML dir for real language sections.
Frequently Asked Questions
It sets the base inline direction for text, table and grid columns, and horizontal overflow. Use ltr for left-to-right languages and rtl for right-to-left languages such as Arabic or Hebrew.
The initial value is ltr. The property is inherited, so children follow a parent unless they override it.
Prefer the HTML dir attribute on the document or a section when you can. MDN recommends avoiding CSS direction for page-level language direction. Use the CSS property for component-level layout demos or when you cannot change markup.
direction sets the base flow and inline start/end sides. text-align places lines inside the box. Prefer text-align: start so alignment follows direction automatically.
On inline-level elements, direction needs unicode-bidi set to embed or override to take effect. Block containers usually show the change without that.
It is Baseline Widely available across modern browsers and older engines. It is a browser CSS property, not a Node.js runtime feature.