HTML ping Attribute
The HTML ping attribute specifies one or more URLs that can be notified when a user follows a hyperlink. It is used for hyperlink auditing, such as recording that a particular link was followed.
Elements That Use the ping Attribute
The ping attribute can be used on HTML elements that create hyperlinks.
ping Value
The value of the ping attribute is a space-separated list of one or more HTTP or HTTPS URLs. Each URL identifies a resource that can receive a notification when the hyperlink is followed.
<a href="https://www.example-web.site/"
ping="https://example.com/track">Visit Example Site</a>
The href attribute specifies the page the user visits, while ping specifies a separate URL that can receive the hyperlink-auditing request.
How ping Works
When a user follows a hyperlink that has a ping attribute, a supporting browser can send an HTTP POST request to each specified ping URL. The request is sent separately from the navigation to the destination specified by href.
<a href="products.html"
ping="https://example.com/link-audit">View Products</a>
Following the link navigates to products.html while the browser can notify the URL specified by ping.
Multiple ping URLs
More than one notification URL can be specified by separating the URLs with spaces.
<a href="products.html"
ping="https://example.com/audit https://example.net/analytics">View Products</a>
A supporting browser can send a separate notification request to each URL when the hyperlink is followed.
Privacy and Browser Settings
The ping attribute is commonly associated with hyperlink auditing and tracking. Browsers can allow users to control this behavior and may ignore some or all ping URLs according to browser settings or user preferences.
Because support and behavior can differ between browsers, a website should not depend on ping for functionality that is required for a link or application to work correctly.
Common Mistakes
Do not separate multiple ping URLs with commas. The ping attribute uses a space-separated list of URLs.
Do not confuse the ping URL with the hyperlink destination. The href attribute identifies where the user navigates, while ping identifies resources that can receive hyperlink-auditing requests.
Do not use non-HTTP or non-HTTPS URLs as ping destinations. The URLs specified by the ping attribute must use the HTTP or HTTPS scheme.
Do not rely on ping for essential website functionality because browsers or user preferences can prevent ping requests from being sent.
Browser Support
Baseline: Limited availability indicates that a feature is not yet available in all core browsers. Use these features with caution because they may only work in select browsers, so additional compatibility checks may be needed before general use.
The ping attribute has limited availability because support and default behavior are not consistent across all core browsers. Browser settings and user preferences can also affect whether ping requests are sent.
Checking Browser Support
For current browser compatibility information, visit Can I Use? . Search for the HTML element or attribute you want to check. You can also narrow your search by entering an element name and attribute name separated by a colon. Search results can include related HTML features, element attributes, input types, APIs, and other technologies, so select the result that most closely matches the feature you are checking.
Try the ping Attribute
The example shows how the ping attribute is added to a hyperlink. The example uses a demonstration ping URL and is intended to show the HTML syntax rather than provide a working tracking service.
Summary
The HTML ping attribute specifies one or more HTTP or HTTPS URLs that can receive notifications when a user follows a hyperlink. It can be used on the <a> and <area> elements for hyperlink auditing, but browser support and user preferences can affect whether the requests are sent.
