HTML DOM dir attribute
Definition and Usage
dir property sets or returns the direction of text elements.
grammar
HTMLElementObject.dir=text-direction
Browser Support
All major browsers support the dir attribute
Examples
Examples
Returns the text direction of the body element:
<html>
<body id="myid" dir="rtl">
<script>
var x=document.getElementsByTagName('body')[0];
document.write("Text direction: " + x.dir);
document.write("<br>");
document.write("An alternate way: ");
document.write(document.getElementById('myid').dir);
</script>
</body>
</html>
<body id="myid" dir="rtl">
<script>
var x=document.getElementsByTagName('body')[0];
document.write("Text direction: " + x.dir);
document.write("<br>");
document.write("An alternate way: ");
document.write(document.getElementById('myid').dir);
</script>
</body>
</html>
try it"