The canonical tag is an HTML link element that tells search engines which URL is the master version of a page when duplicate or near-duplicate versions exist.
The element lives in the <head> of the page:
<link rel="canonical" href="https://example.com/canonical-url/">
When Google encounters this element, it treats the declared URL as the preferred version. If a page is reachable as /product?id=42, /product/42/ and /product/42?ref=newsletter, a canonical to /product/42/ consolidates the three under one indexable URL.
It is a hint, not a directive. Google can ignore it when the declared URL returns 404, is blocked by robots.txt, or contains content materially different from the page that declares it.