---
title: Document.dir
slug: Web/API/Document/dir
tags:
  - API
  - Document
  - HTML DOM
  - Property
  - Reference
browser-compat: api.Document.dir
---
{{ApiRef("HTML DOM")}}

The **`Document.dir`** property is a {{domxref("DOMString")}}
representing the directionality of the text of the document, whether left to right
(default) or right to left. Possible values are `'rtl'`, right to left, and
`'ltr'`, left to right.

## Syntax

```js
dirStr = document.dir
document.dir = dirStr
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [`dir`](/en-US/docs/Web/HTML/Global_attributes/dir) global
  attribute
