{"id":14047,"date":"2011-09-05T20:41:56","date_gmt":"2011-09-06T03:41:56","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14047"},"modified":"2021-03-29T08:10:00","modified_gmt":"2021-03-29T15:10:00","slug":"direction","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/d\/direction\/","title":{"rendered":"direction"},"content":{"rendered":"\n
The The valid values are:<\/p>\n\n\n\n The text on this page is set in the default \u0637\u0647\u064a\u0633 \u064a\u0633 \u062a\u0622\u062e\u062a \u062a\u0647\u0627\u062a \u064a\u0633 \u0648\u0631\u064a\u062a\u062a\u0622\u0646 \u0641\u0631\u0648\u0645 \u0631\u064a\u063a\u062a \u062a\u0648 \u0644\u0622\u0641\u062a \u062a\u0647\u0627\u062a \u064a\u0633 \u0648\u0633\u0622\u062f<\/p>\n\n\n\n There is an HTML attribute for setting the direction as well:<\/p>\n\n\n\n Both the CSS property and the HTML attribute will cascade the direction to descendent elements. It is recommended you use the HTML attribute, as that will work even if CSS fails or doesn’t affect the page for any reason.<\/p>\n\n\n\n There is also a specific HTML tag that can be used for changing the direction of text: To pair all this with CSS…<\/p>\n\n\n\n “bidi” = “bi-directional”<\/p>\n\n\n\n When creating layouts in a pre-flexbox pre-grid world, people often chose between floats and inline-block to create columns. One advantage to inline-block, other than removing the need to clear the float, is that changing the direction property reverses the layout as well. This isn’t true for floats, which would need to be reset if a webpage supports multiple languages and the language direction changed from ltr to rtl or vice versa.<\/p>\n\n\n\n If you need to change the direction of an inline element (against what its parent block level element is), you’ll either need to use the element, or ensure the inline element sets the The direction property in CSS sets the direction of of content flow within a block-level element. This applies to text, […]<\/p>\n","protected":false},"author":1036,"featured_media":0,"parent":13917,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"page-almanac-single.php","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","_share_on_mastodon":"0","_share_on_mastodon_status":"%title% %permalink%"},"tags":[],"acf":[],"share_on_mastodon":{"url":"","error":""},"jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14047"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/1036"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=14047"}],"version-history":[{"count":9,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14047\/revisions"}],"predecessor-version":[{"id":337260,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/14047\/revisions\/337260"}],"up":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/pages\/13917"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=14047"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=14047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}direction<\/code> property in CSS sets the direction of of content flow within a block-level element. This applies to text, inline, and inline-block elements. It also sets the default alignment of text and the direction that table cells flow within a table row.<\/p>\n\n\n\n
.main-content {\n direction: rtl; \/* Right to Left *\/\n}<\/code><\/pre>\n\n\n\n
ltr<\/code> – Left to Right, the default<\/li>
rtl<\/code> – Right to Left<\/li>
inherit<\/code> – inherits its value from the parent element<\/li><\/ul>\n\n\n\n
ltr<\/code> direction. The most common use case to set
rtl<\/code> is for web pages with Hebrew or Arabic text. Here is an example of Arabic set in rtl:<\/p>\n\n\n\n
<p dir=\"rtl\">This paragraph goes from right to left.<\/p><\/code><\/pre>\n\n\n\n
<\/bdo><\/code> the bidirectional override element<\/em>. This exists so there is a semantics-free element to use just for this purpose. For instance:<\/p>\n\n\n\n
<bdo dir=\"rtl\">This text will go right to left.<\/bdo><\/code><\/pre>\n\n\n\n
*[dir=\"ltr\"] { direction: ltr; unicode-bidi: embed; }\n\n*[dir=\"rtl\"] { direction: rtl; unicode-bidi: embed; }\n\nbdo[dir=\"ltr\"] { direction: ltr; unicode-bidi: bidi-override; }\n\nbdo[dir=\"rtl\"] { direction: rtl; unicode-bidi: bidi-override; }<\/code><\/pre>\n\n\n\n
unicode-bidi<\/code> property properly:<\/bdo><\/p>\n\n\n\n
Some regular text <bdo dir=\"rtl\">reverse direction<\/bdo> text text <span dir=\"rtl\">reverse direction<\/span>\n<\/code><\/pre>\n\n\n\n
span[dir] {\n unicode-bidi: bidi-override;\n}<\/code><\/pre>\n\n\n
Related Properties<\/h3>\n\n\n
unicode-bidi<\/code><\/a><\/li><\/ul>\n\n\n
Other Resources<\/h3>\n\n\n
Browser Support<\/h3>\n\n\n
Chrome<\/th> Safari<\/th> Firefox<\/th> Opera<\/th> IE<\/th> Android<\/th> iOS<\/th><\/tr><\/thead> 2.0+<\/td> 1.3+<\/td> Any<\/td> 9.2+<\/td> 5.5+<\/td> Any<\/td> 3.1+<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"