Search code examples
javascripthtmlcssinternationalizationright-to-left

Flow of divs in right-to-left language


Is it possible in HTML to mark a group of divs so that they flow from left-to-right for left-to-right languages while flowing right-to-left for right-to-left languages? That is, the flow would depend on the setting of the html lang attribute. For example, if you had the following

<html lang="en">

the flow of the marked divs would be left-to-right, while if the language was Hebrew (a right-to-left language)

<html lang="he">

the flow of the marked divs would be right-to-left.


Solution

  • Use the dir attribute as well. It can go on any div so you can change it on the fly.

    <html lang="he" dir="rtl">
    

    Don't forget: You might have some CSS to worry about. I use a project called R2 to help with that.