HTML ping Attribute
Description
The HTML ping
attribute is used to send a short notification to a URL when the user clicks on a hyperlink. This attribute can be included within <a>
, <area>
, or <form>
elements, and its primary purpose is to provide webmasters with a simple way to track clicks or to log user visits to external links without interrupting the user's browsing experience.
When a user clicks on an element that has a ping
attribute, the browser sends a POST request to the specified URL(s) in the background. Multiple URLs can be specified by separating them with a space. This process is transparent to the user, allowing for the collection of analytics data or other information without affecting the user's interaction with the website. It's worth noting that the ping
attribute does not alter the behavior of the hyperlink itself; the browser will still navigate to the link's href
attribute as usual.
However, due to privacy concerns and potential misuse, the support and behavior of the ping
attribute may vary across different browsers and user settings. Some browsers may offer users the option to disable this feature, or it may not be supported at all. Therefore, web developers should consider these factors and not solely rely on the ping
attribute for critical analytics or tracking purposes.
Syntax
<a href="URL" ping="list-of-URLs" />
Values
- list-of-URLsA space-separated list of URLs.
Applies To
The ping
attribute can be used on the following html elements.
Example
<a href="https://www.example.com" ping="https://analytics.example.com/track-link-click">Click here</a>
Browser Support
The following table will show you the current browser support for the HTML ping
Attribute.
Desktop | |||||
![]() |
![]() |
![]() |
![]() |
![]() |
|
17 | 12 | 1 | 15 | 6 |
Tablets / Mobile | |||||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
18 | 4 | 14 | 6 | 1 | 37 |
Last updated by CSSPortal on: 29th March 2024