The <geolocation> element creates an interactive, browser-defined control for sharing the user’s location with the page. It provides a built-in UI, permission flow, and a DOM API (HTMLGeolocationElement) for reading position data and errors.
With watch, location events can fire repeatedly as the device moves.
How It Works
Add boolean watch for continuous updates.
Listen for location each time a new position arrives.
Read geo.position or geo.error on the element.
Fallback path: use navigator.geolocation.watchPosition() (see API tutorial).
Watch out
Edge Cases & Pitfalls
quota
Max three per page
Browsers may disable all <geolocation> elements if more than three appear on one page.
blocking
Invalid / blocked controls
Anti-abuse rules can mark an element invalid (check isValid / invalidReason). Conscious user activation is required.
css
Strict styling limits
Contrast, font-size, and other CSS constraints apply. Violations can deactivate the control.
secure
Secure contexts
Location APIs need HTTPS (or localhost). Insecure origins will fail like the classic API.
api
Do not confuse with the tutorial URL
/html/geolocation is the Geolocation API guide. This page is the HTML tag at /html/tags/geolocation.
support
Always ship a fallback
Firefox and Safari may not support the element yet. Nest a button that uses navigator.geolocation.
Compatibility
Browser Support
The <geolocation>element is experimental HTML with limited availability. It is not a Node.js, Deno, or Bun API.
✓ Experimental · Limited
<geolocation>
Not Baseline. Early support in Chromium-based browsers (for example Chrome/Edge around 144+). Firefox and Safari: not supported yet — use a Geolocation API fallback.
30%Global support (approx.)
Google Chrome144+
Supported (exp.)
Mozilla Firefox—
Not supported
Apple Safari—
Not supported
Microsoft Edge144+
Supported (exp.)
Opera131+
Supported (exp.)
Samsung Internet31+
Check / rolling
Internet Explorer—
Not supported
<geolocation>Experimental
Bottom line: Treat as progressive enhancement. Link learners to /html/geolocation for the widely available JavaScript API.
Remember
Key Takeaways
Role: declarative browser control for sharing location.
Attrs:autolocate and watch (boolean).
Fallback: nest a button using the Geolocation API.
One line:<geolocation> is an experimental declarative location control — always ship a Geolocation API fallback.
UA style
Default CSS Settings
Supporting browsers render a native control (for example a map-pin button). Styling is heavily constrained for accessibility and anti-spoofing:
default.css
/* Conceptual — exact UA styles vary */
geolocation {
/* browser-defined interactive control */
/* contrast, font-size, opacity, and other constraints apply */
}
Prefer minimal styling. Violating contrast or size rules can deactivate the control.
Frequently Asked Questions
The geolocation element creates a browser-defined interactive control that lets the user share their location with the page. It handles permissions UI and exposes position data through HTMLGeolocationElement.
When present, the browser may retrieve location as soon as the element is rendered — but only if permission was already granted. If permission was never granted, autolocate has no effect until the user activates the control.
When present, the browser updates location whenever the device position changes (like Geolocation.watchPosition). Without it, location is retrieved once (like getCurrentPosition).
The Geolocation API tutorial at /html/geolocation covers navigator.geolocation in JavaScript. This tag page documents the declarative <geolocation> element, which uses that API under the hood with a built-in control.
Yes. Put a message or a button between the tags. Unsupported browsers show that content; supporting browsers show the native control instead.
It is experimental with limited availability (for example Chromium-based browsers). Prefer the Geolocation API with your own UI until support is wider, or use progressive enhancement with a fallback button.