HTML | DOM Bdo dir Property

The Bdo dir Property in HTML DOM is used to set or return the value of the text direction of an element. The dir attribute defines the text direction of an element.

Syntax:

  • It is used to return the text direction property.
    bdoObject.dir
  • It is used to set the text direction property.
    bdoObject.dir = "ltr|rtl"

Property Values:

  • ltr: It defines the left-to-right text direction.
  • rtl: It defines the right-to-left text direction.

Return Value: It returns a string value which represent the text direction of an element.

Example 1: This example illustrates how to set the dir Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
    <head
        <title>
            HTML DOM Bdo dir Property
        </title>
    </head
  
    <body style="text-align:center;"
          
        <h1>GeeksForGeeks</h1
          
        <h2>DOM Bdo dir Property</h2
          
        <bdo id="GFG" dir="rtl"
            A Computer science portal for geeks 
        </bdo><br
          
        <button onclick="myGeeks()">
            Submit
        </button
          
        <script
            function myGeeks() { 
                document.getElementById("GFG").dir = "ltr";
            
        </script
    </body
</html>                    

chevron_right


Output:
Before Click on the button:

After Click on the Button:

Example 2: This example illustrates how to return the dir Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
    <head
        <title>
            HTML DOM Bdo dir Property
        </title>
    </head
  
    <body style="text-align:center;"
      
        <h1>GeeksForGeeks</h1>
          
        <h2>DOM Bdo dir Property</h2
          
        <bdo id="GFG" dir="rtl"
            A Computer science portal for geeks 
        </bdo><br
          
        <button onclick="myGeeks()">
            Submit
        </button>
          
        <p id="sudo" style="font-size:35px;color:green;"></p
          
        <script
            function myGeeks() { 
                var w = document.getElementById("GFG").dir;
                document.getElementById("sudo").innerHTML = w;
            
        </script
    </body
</html>                    

chevron_right


Output:
Before Click on the Button:

After Click on the Button:

Supported Browsers: The browser supported by DOM Bdo dir property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.