Set the text direction of a <p> element to "right-to-left":
document.getElementById("demo").style.direction = "rtl";
Try it Yourself »
The direction property sets or returns the text direction (reading order) of an element's content.
Property | |||||
---|---|---|---|---|---|
direction | Yes | Yes | Yes | Yes | Yes |
Return the direction property:
object.style.direction
Set the direction property:
object.style.direction = "ltr|rtl|initial|inherit"
Value | Description |
---|---|
ltr | Text flows from left to right. This is default |
rtl | Text flows from right to left |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | ltr |
---|---|
Return Value: | A String, representing the text direction of an element |
CSS Version | CSS2 |
Return the text direction of a <p> element:
alert(document.getElementById("demo").style.direction);
Try it Yourself »
CSS tutorial: CSS Text
CSS reference: direction property
HTML reference: HTML dir Attribute
HTML DOM reference: HTML DOM dir Property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!