Open In App

HTML | DOM Style right Property

The Style right property in HTML DOM is used to set or return the right position of a positioned element including padding, scrollbar, border, and margin. 

Syntax:



object.style.right
object.style.right = "auto|length|%|initial|inherit"

Return Values: It returns a string that represents the right position of a positioned element

Property Value Description:



Example 1: 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML | DOM Style right Property
    </title>
    <style>
        #GfG {
            position: absolute;
            background-color: green;
            color: white;
        }
    </style>
</head>
 
<body>
 
    <h1> Geeks for Geeks </h1>
    <h2> HTML|DOM Style right Property </h2>
 
    <button onclick="myFunction()">Click here</button>
 
    <GfG id="GfG">
        <h1>GfG</h1>
    </GfG>
 
    <script>
        function myFunction() {
            document.getElementById("GfG")
            .style.right = "100px";
        }
    </script>
 
</body>
 
</html>

Output:




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML | DOM Style right Property
    </title>
    <style>
        #myGfG {
            border: 1px solid #FF0000;
            position: relative;
        }
    </style>
</head>
 
<body>
 
    <h1> Geeks for Geeks </h1>
    <h2> HTML|DOM Style right Property </h2>
 
    <GfG id="myGfG">Welcome to Geeks for Geeks.</GfG>
    <br>
 
    <button type="button" onclick="myFunction()">
     Click Here!
    </button>
 
    <script>
        function myFunction() {
            document.getElementById("myGfG")
                .style.right = "-200px";
        }
 
        < GfG id = "myGfG" > Welcome to Geeks
        for Geeks. < /GfG> < br >
 
        < button type = "button"
        onclick = "myFunction()" > Click Here! < /button>
 
        < script >
            function myFunction() {
                document.getElementById("myGfG")
                    .style.right = "-200px";
            }
    </script>
 
</body>
 
</html>
</script>
 
</body>
</html>

Supported Browsers:


Article Tags :