What is an easy way to explain the difference between the attributes rel
and type
in html tags?
Here's an example:
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
And why are both needed? In the above example, there seems to be a pretty strong overlap between the two.
Bonus - is there an explanation of how are these tags used by the browser that would help one understand the need for both of these attributes in the above <link>
example?
CodePudding user response:
type
defines the MIME type, whereas rel
defines the relation to the document.
MIME types include image/png, text/plain, application/json, ….
Possible relation types include stylesheet, icon, author, help, ….
CodePudding user response:
The type
attribute describes the data format the link points to. "This is a Windows Icon file", "This is a PNG image", "This is an HTML document".
The rel
attribute describes what connection (relationship) it has to the current document. "This is to be displayed as the Favicon", "This is the next document in a sequence", "This is another document that has the same content as this one but in a different format".