GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — HTMLElement: dir property - Web APIs | MDN

HTMLElement: dir property

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

  • See full compatibility
  • Learn more

The HTMLElement.dir property indicates the text writing directionality of the content of the current element. It reflects the element's dir attribute.

Note that if the dir attribute is unspecified, the element itself may still inherit directionality from its parent. However, that inherited directionality is not reflected by this property's value.

The text writing directionality of an element is which direction that text goes (for support of different language systems). Arabic languages and Hebrew are typical languages using the RTL directionality.

Value

One of the following:

"ltr"

Left-to-right writing direction.

"rtl"

Right-to-left writing direction.

"auto"

The direction of the element must be determined based on the contents of the element.

""

The default value; the directionality is inherited from the parent element.

Examples

js
const para = document.getElementById("para1");
para.dir = "rtl";
// change the text direction on a paragraph identified as "para1"

Specifications

Specification
HTML
# dom-dir

Browser compatibility

See also

  • document.dir
  • HTML dir global attribute
  • CSS direction property
  • CSS :dir pseudo-class

Help improve MDN

Learn how to contribute

This page was last modified on Apr 10, 2025 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.