HTML DOM Element dir attribute
- الصفحة السابقة contentEditable
- الصفحة التالية firstChild
- العودة إلى الطبقة السابقة كائن HTML DOM Elements
definition and usage
dir
attribute sets or returns the dir attribute of the element.
dir
attribute specifies text direction.
see also:
example
Example 1
Change the text direction of "myP" to "right-to-left":
document.getElementById("myP").dir = "rtl";
Example 2
Return the text direction of the document:
document.body.dir;
Example 3
Set the text direction of the document:
document.body.dir = "rtl";
syntax
Return dir attribute:
element.dir
Set dir attribute:
element.dir = "ltr|rtl|auto"
attribute value
value | description |
---|---|
ltr | left-to-right text direction (default). |
rtl | right-to-left text direction. |
auto | let the browser decide. |
return value
type | description |
---|---|
string | the text direction of the element. |
browser support
all browsers support element.dir
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
الدعم | الدعم | الدعم | الدعم | الدعم | الدعم |
- الصفحة السابقة contentEditable
- الصفحة التالية firstChild
- العودة إلى الطبقة السابقة كائن HTML DOM Elements