A canonical tag defines the search engine that a specific URL represents the master or main copy of a webpage. By using canonical tag one can prevent the difficulty of duplicate content displaying on multiple URLs.
As we all know that Google or other search engines penalize URLs with duplicate content so canonical tags are the solution.
In other words, if you have any duplicate content on different URLs we can make it clear to the search engine by using a canonical tag which one is the main URL and which one has to be indexed.
Here is the syntax of the canonical tag in HTML:
<head>
<link rel=“canonical” href=“canonical/main URL here” />
</head>