HTML DOM Geolocation coords.latitude Property (original) (raw)
Last Updated : 23 Jul, 2025
In this article, we will discuss the Geolocation latitude 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.
coords.latitude: This property will return the latitude as a decimal number.
Please refer to the HTML Geolocation article for further details about the other location properties.
Syntax:
coords.latitude
Return Value:- This property returns the latitude as a decimal number.
Example: The following HTML code will return the latitude.
HTML `
GeeksforGeeks
Displaying location using latitude
<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 = "Latitude: "
+ pos.coords.latitude;
}
</script>
`
Output:

Supported Browsers:
- Google Chrome
- Microsoft Edge
- Firefox
- Opera
- Safari