Question: Is it possible to get the writing mode of the user? I'd like to know if the the text is RTL or LTR and TB. 

It looks like I can get the direction and writing mode from the computedValue.

```css
#div2 {
  writing-mode: vertical-lr;
}

#div1 {
  direction: rtl;
}

p {
  background-color: #FFEECC;
}
```

```html
<p>While the characters in most scripts are written from left to right, certain scripts are written from right to left.</p>

<p id="div1">While the characters in most scripts are written from left to right, certain scripts are written from right to left. In some documents, in particular those written with the Arabic or Hebrew script, and in some mixed-language contexts, text in a single (visually displayed) block may appear with mixed directionality. This phenomenon is called bidirectionality, or "bidi" for short.</p>

<p id="div2">While the characters in most scripts are written from left to right, certain scripts are written from right to left. I</p>
```

Or is there a recommended way to get this information, like IME mode? 

Is getting the direction and writing mode or language the way to show consideration for other languages?

<https://www.w3.org/TR/css-writing-modes-3/>

<https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Relationship_of_Flexbox_to_Other_Layout_Methods#Writing_Modes>

Answer: 
Answer:
-------

Use the [`getComputedStyle`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle) `Window` method.

```
 getComputedStyle(document.body).direction;
 getComputedStyle(document.body)["writing-mode"];

```

---

Why?
----

Unlike simply accessing the `style` object of a node which may return an empty string by default (a.e. `direction` is defaulted to "ltr" but will return ""), *getComputedStyle* will return the value of the styling requested every time including default values.

---

Example:
--------

```js
let direction = getComputedStyle(document.body).direction;
let writing_mode = getComputedStyle(document.body)["writing-mode"];
console.log(direction, writing_mode);
```

---

Aside:
------

It can also be used in combination with [Destructuring Assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment):

```
let {direction, "writing-mode": writing_mode} = getComputedStyle(document.body);

```

```js
let {direction, "writing-mode": writing_mode} = getComputedStyle(document.body);
console.log(direction, writing_mode);
```
The HTML document has a "direction" attribute that specifies the language direction for its contents, but this does not represent the reading direction of the user (i.e. an american user in the US can visit a japanese website and the content's reading direction is RTL).

Instead, you can get the user's browser language using Javascript to check the global property:

```
navigator.language

```

This will get you an ISO language (i.e. "en-US") code which you can compare to an array of ISO codes for RTL languages (easy to gather from google), as well as a list of ISO codes for BTT languages.