hreflang tags or attributes are used to communicate to search engines the language used within a content page and to showcase variations of content based on users' locations.
The hreflang tag, also referred to as hreflang attribute, is used to communicate to search engines what language a website uses on specific pages. This helps crawlers and search engines index the content properly and display it as a result in the search engine page results for people searching in that language.
To easily add (or identify) a hreflang tag in a page, use rel="alternate" hreflang="x". Here's a code sample for 2 variations of English on the same site:
<link rel="alternate" href="https://yourwebsite.com" hreflang="en-us" />
<link rel="alternate" href="https://yourwebsite.com" hreflang="en-uk" />
The main reason to use a hreflang attribute on a site is for localization purposes and to inform search engines about the language used on specific pages. If a website has multiple languages for the same page, the hreflang tag showcases the fact that there is targeted content for multiple languages or even variants of a single language. This is an extremely helpful tag to have on a website with variations in terms of currency, culture, or shipping.