To return the position of the element relative to floating objects, use the clear property in JavaScript.
Example
You can try to run the following code to learn how to return the position of the element.
<!DOCTYPE html> <html> <head> <style> img { float: left; } </style> </head> <body> <img src="https://www.tutorialspoint.com/videotutorials/images/tutor_connect_home.jpg" width="170" height="150"> <p id="myP">Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content! Demo content!</p> <button type="button" onclick="display()">Click</button> <script> function display() { document.getElementById("myP").style.clear = "left"; } </script> </body> </html>