Direction property

Last updated: 2026-09-13

direction Direction property

The direction CSS property sets the text writing direction — left-to-right (ltr) or right-to-left (rtl). It mainly affects right-to-left languages such as Arabic and Hebrew and also changes text alignment, scrollbar position, and layout flow. For multilingual sites, prefer the dir attribute on the HTML element over the CSS property.

Category
Initial Valueltr
InheritedYes
Applies To
Animation Type
CSS VersionCSS2
StatusStandard

📝 Syntax

direction: ltr | rtl;

⚙️ Values

ValueTypeDescription
ltr | rtlKeywordText direction

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
direction v10 v12 v1 v1 v1
Supported in all major browsers
Tip: For RTL languages, use dir="rtl" directly on the HTML element — it is more semantic and automatically affects the whole document flow.
Important: direction changes the physical mapping of logical properties like margin and padding; combining it with CSS logical properties such as margin-inline-start gives better internationalization support.

❓ FAQ

QWhat is the difference between direction and writing-mode in CSS?
Adirection controls the flow of text horizontally (left-to-right or right-to-left); writing-mode controls the overall layout direction of the text, horizontal or vertical. They can be combined to produce different typographic layouts.
QWhy does the page layout change after I set direction: rtl in CSS?
Adirection: rtl reverses the text flow, so text starts from the right edge and the scrollbar also moves to the left. If you only want to change text alignment without affecting layout, use text-align instead.
QHow do I set a right-to-left layout for Arabic or Hebrew text on my site?
AWrite dir="rtl" on the <html> or <body> element — it is more semantic than CSS direction: rtl and also affects browser behavior like forms and scrollbars. In CSS you can write direction: rtl and pair it with unicode-bidi for mixed text.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏