Web API DOMRect top property Last Updated : 15 Jun, 2023 Comments Improve Suggest changes Like Article Like Report In Web API there is a DOMRect Interface which has a property top that gives us the top of the DOMRect object. It returns the y coordinate value or if the height is negative then it returns y + height. Syntax: let recX = DOMRect.top; Return Type: Double value Example 1: When the height is positive HTML <!DOCTYPE html> <html> <head> <title> DOMRect top property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect top property</h2> <button onclick="getDOMRect ();"> Get top </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect(0, 0, 100, 100); let rectop = myDOMRect.top; document.getElementById( 'DOMRect').innerHTML = rectop; } </script> </body> </html> Output: Example 2: When the height is negative HTML <!DOCTYPE html> <html> <head> <title> DOMRect top property </title> </head> <body> <h1 style="color:green;"> GeeksForGeeks </h1> <h2>DOMRect top property</h2> <button onclick="getDOMRect ();"> Get top </button> <p id='DOMRect'></p> <script type="text/javascript"> function getDOMRect() { let myDOMRect = new DOMRect(0, 0, 100, -100); let rectop = myDOMRect.top; document.getElementById('DOMRect').innerHTML = rectop; } </script> </body> </html> Output: Supported Browsers: The browsers supported by DOMRect top property are listed below: Google ChromeSafari 10.1FirefoxOpera Comment More info D DeepakDev Follow Improve Article Tags : Web Tech Web technologies HTML-DOM Web-API Explore HTML & CSS TutorialsHTML Tutorial8 min readCSS Tutorial6 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readJS TutorialJavaScript Tutorial7 min readJSON Tutorial5 min readTypeScript Tutorial8 min readVue.js Tutorial4 min readjQuery Tutorial8 min readFront EndReact Tutorial6 min readNext.js Tutorial6 min readAngular Tutorial4 min readBackendNode.js Tutorial4 min readExpress.js Tutorial4 min readPHP Tutorial8 min readLaravel Tutorial3 min readDjango Tutorial | Learn Django Framework7 min readDatabaseMongoDB Tutorial7 min readRedis Introduction4 min readSQL Tutorial7 min readMySQL Tutorial10 min read Like