{"id":20517,"date":"2013-03-12T15:40:28","date_gmt":"2013-03-12T22:40:28","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=20517"},"modified":"2021-11-25T11:17:20","modified_gmt":"2021-11-25T19:17:20","slug":"unicode-bidi","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/u\/unicode-bidi\/","title":{"rendered":"unicode-bidi"},"content":{"rendered":"\n

The unicode-bidi<\/code> property is one of two CSS properties that handle the rendering of bi-directional text in HTML and similar markup-based languages (eg XML<\/abbr>). The other property is direction<\/code><\/a>, and the two are used together to create levels of embedded text with different text directions (right-to-left and left-to-right) in a single DOM element.<\/p>\n\n\n\n

.bilingual-excerpt {\n    direction: rtl;\n    unicode-bidi: embed;\n}<\/code><\/pre>\n\n\n\n

The browser usually determines which direction inline text will flow, depending on the lang<\/code> attribute of elements, the browser’s locale, and font-family<\/code> of specific elements. unicode-bidi<\/code> comes in handy when an element contains both LTR text and RTL text:<\/p>\n\n\n\n

The user agent applies a complex algorithm defined by the Unicode standard to determine how the text should appear. This property specifically controls the embedding levels and overrides for the Unicode bidirectional algorithm.<\/p><\/blockquote>\n\n\n\n

The unicode-bidi<\/code> property has three widely-supported values:<\/p>\n\n\n\n

  1. the \u201cnormal\u201d keyword, which offers no additional levels of embedded bi-directional text (the default browser behavior). An element with this property will only contain LTR or RTL text.<\/li>
  2. the \u201cembed\u201d keyword, which allows for bi-directional text in an element (for example, RTL text flowing amidst LTR text). This is determined by the direction<\/code> property, and must be applied to an inline element.<\/li>
  3. the \u201cbidi-override\u201d keyword, which acts the same as \u201cembed\u201d when applied to inline elements. On block-level elements, it overrides the browser’s bi-directional text algorithm and flows the text inside any inline children strictly according to the direction<\/code> property.<\/li><\/ol>\n\n\n

    Points of interest<\/h3>\n\n\n