ping

The HTML ping attribute designates URLs that will be notified when a user clicks a link, enabling tracking without affecting the user's browsing experience.

Ping Attribute

The ping attribute in HTML is used to send a brief notification to specified URLs when a user clicks on a hyperlink. This attribute can be applied to <a>, <area>, or <form> elements. Its primary purpose is to allow webmasters to track clicks or log user visits to external links without interfering with the user's browsing experience.

Syntax

index.html
<a ping="URL">
Please note that this feature does not work in Firefox and may have limited functionality due to privacy and security restrictions.

Example

Here’s an example demonstrating the use of the ping attribute:

<a
  id="exampleLink"
  href="https://example.com"
  ping="https://example-tracking.com https://example-analytics.com"
  >Example Link</a
>

Values

  • list-of-URLs
    • A space-separated list of URLs that will be notified when the link is clicked.

Applies To

The ping attribute can be used on the following HTML elements:

Conclusion

The ping attribute in HTML is used to notify specified URLs when a user clicks on a link, helping track clicks or log user activity without disrupting the browsing experience. It works with <a>, <area>, and <form> elements and allows for a space-separated list of URLs. However, due to privacy concerns, this feature may not function in all browsers, such as Firefox.