Javascript examples for CSS Style Property:direction
The direction property sets or gets the text direction.
Value | Description |
---|---|
ltr | Text displays from left to right. This is default |
rtl | Text displays from right to left |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | ltr? |
Return Value: | A String, representing the text direction of an element |
CSS Version | CSS2 |
Set the text direction of a <p> element to "right-to-left":
<!DOCTYPE html> <html> <body> <p id="myP" style="direction:rtl;">This is an example paragraph.</p> <button type="button" onclick="myFunction()">Return text direction</button> <script> function myFunction() {/*from w ww .j a va 2 s . c om*/ document.getElementById("myP").style.direction = 'rtl'; } </script> </body> </html>