You are here: Reference > JavaScript > client-side > style handling > properties > pixelRight

pixelRight property

Browser support:
Specifies or retrieves the value of the right style property, in pixels.
With the bottom style property you can set or return the right position of an element with a unit designator as a string. The pixelRight property specifies or retrieves the right position as an integer, in pixels. When the value of the pixelRight property is set, the unit type of the right style property is not changed. The value will be converted to the current unit type of the right style property. If you want to set or retrieve the right position as a floating-point number that specifies the value in the current unit type of the right style property, use the posRight property.
The properties mentioned above can be used to access style settings. If you need the right position of a rendered element, you can use the offsetLeft, offsetWidth properties and the getBoundingClientRect method.
The currentStyle.pixelRight property is read-only, all others are read/write.


You can find the related objects in the Supported by objects section below.

Possible values:

Integer that sets or returns the right position, in pixels.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the pixelRight property:
    <script type="text/javascript">
        function GetRightPos (elem) {
            var rightStyle =;
            var rightPos =;
            var rightPx =;
            alert ("The right position of the button: " + rightStyle +
                   "\n without unit type: " + rightPos + 
                   "\n in pixels: " + rightPx); 
    <button style="position:absolute; right:10%; bottom:40%; width:160px; height:30px;" 
            onclick="GetRightPos (this);">Get right position!</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content