HTML DOM Geolocation coords.accuracy Property (original) (raw)

Last Updated : 23 Jul, 2025

In this article, we will discuss the Geolocation accuracy property. Geolocation in HTML is used to get the geographical position of a user. The getCurrentPosition() method in this geolocation returns an object on success.

HTML Geolocation coords.accuracy Property: This property will return the accuracy of the location as a decimal number

Syntax:

coords.accuracy

Example: The following HTML program returns the accuracy.

HTML `

GeeksforGeeks

Displaying Accuracy

<button onclick="getlocation()"> 
    Click Me 
</button>

<p id="paraID"></p>


<script>
    var variable1 = document.getElementById("paraID");

    function getlocation() {
        navigator.geolocation.getCurrentPosition(showLoc);
    }

    function showLoc(pos) {
        variable1.innerHTML = "Accuracy: "
            + pos.coords.accuracy;
    }
</script>

`

Output:

Supported Browsers: