ping
The ping attribute for <a> elements sets a URL to send a POST request to when the <a> is clicked. This is typically used for outbound link reporting. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Overview
The ping attribute for <a> elements sets a URL to send a POST request to when the <a> is clicked. This is typically used for outbound link reporting. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 12 | 17 | 1 | 5.1 | 18 | 5 | |
| HTML attribute | ||||||
ping | 12 | 17 | 1 | 6 | 18 | 6 |
ping | 12 | 17 | 1 | 6 | 18 | 6 |
| DOM API | ||||||
| The ping property of the HTMLAreaElement interface is a space-separated list of URLs. When the link is followed, the browser will send POST requests with the body PING to the URLs. | 12 | 17 | 1 | 5.1 | 18 | 5 |
| The ping property of the SVGAElement interface returns a string that reflects the ping attribute, containing a space-separated list of URLs to which, when the hyperlink is followed, POST requests with the body PING will be sent by the browser (in the background). Typically used for tracking. | 144 | 144 | 61 | | 144 | |
| Other | ||||||
svg.elements.a.ping Experimental | | | 61 | | | |
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
- This browser only partially implements this feature
- This property is exposed but has no effect if the `browser.send_pings` preference is not set to `true`. See bug 951104.
Syntax
<a href="https://example.com"
ping="/tracking/click?id=123">
Link with tracking
</a> Use cases
Use ping
Use ping when standard HTML needs a more specific platform feature, semantic signal, or browser capability.
Handle edge cases
Apply ping to solve a focused requirement without redesigning the whole page architecture.
Cautions
- Test ping in your target browsers and input environments before depending on it as a primary behavior.
- Provide a fallback path or acceptable degradation strategy when support is still limited.
Accessibility
- Make sure ping supports the intended task without making the page harder to perceive, understand, or operate.
Related links
Powered by web-features