Skip to content
Related Articles

Related Articles

Improve Article

Web API | DOMRectReadOnly y property

  • Last Updated : 08 Aug, 2019

The y property in DOMRectReadOnly interface is used to represents the y-coordinate of the DOMRect object. It is the read-only property.


var recX = DOMRect.y;

Return Value: It returns the y-coordinate of DOMRectReadOnly object.

Example: This example uses DOMRect.y property to get the y-coordinate of the DOMRect object.

<!DOCTYPE html> 
        Web API DOMRectReadOnly y property
<body style="text-align:center;">
    <h1 style="color:green;"
    <h2>Web API | DOMRectReadOnly y property</h2>
    <button onclick="getDOMRect ();">
        Get y-coordinate
    <p id='DOMRect'></p>
    <script type="text/javascript">
        function getDOMRect () {
            var myDOMRect = new DOMRect(0, 0, 100, 100);
            var recY = myDOMRect.y;
                    = recY;


  • Before Click the Button:
  • After Click the Button:

Supported Browsers: The browsers supported by DOMRectReadOnly y property are listed below:

  • Google Chrome
  • Firefox
  • Safari 10.1
  • Opera

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :