I am reading and taking notes on the HTML specifications for 100 days as part of #The100DayProject. Read the initial intent/backstory. I am a Microsoft employee but all opinions, comments, etc on this site are my own. I do not speak on behalf of my employer, and thus no comments should be taken as representative of Microsoft's official opinion of the spec. Subsections not listed below were read without comment.
Currently reading in 4.2.4 The link element
link element as hyperlink
UAs (User Agents, for ex, browsers) can surface the link element as a clickable/tappable hyperlink somewhere in the UI; not too much strict guidance on how to do that. I didn’t realize that; I previously thought the link element was pretty much only for loading resources or creating relationships between pages for the sake of machines.
Still uncertain of a living use case.
media attribute on the link element
media attribute—which describes what kind of media the document was made for, all, handheld, etc—is handled a little bit differently based on what type of link the element is. If it’s a hyperlink, it’s just sort of nice-to-have information.
If the link is actually loading a resource, that resource has to be applied if and only if the “environment” the document is in matches the value of the media attribute (so you could conceivably load a resource only on handheld devices, for example).
If you don’t set the media attribute, the default value is
Gives the language (human language in ISO values, not a coding language) the linked resource is in, but that’s “purely advisory”.
Also purely advistory, containing a MIME type of the linked resource (likely you’ve seen
text/html). Here’s a giant list of MIME types, can’t personally speak to how accurate or up to date that is.
type attribute can help the UA/browser avoid trying to load a resource it doesn’t support, as UAs are supposed to assume—only when fetching—that the resource type matches the value given. No
type attribute present falls back to a default type. Lack of detail there suggests this may change given certain contexts.
HOWEVER, UAs are not to trust the
type attribute to determine the resource’s type after it has been fetched. There’s a process for using the resource’s Content-Type metadata, and/or applying type sniffing rules.
Only after determining the resource’s true type is the resource applied or not applied, according to UA support and some other rules about relationships between
type (for example, the UA should not apply a link with
Advisory unless it defines “alternative style sheet sets” on a stylesheet link. This attribute doesn’t inherit from the document
title, which makes sense because you’re linking up an external resource or document.
Only used on link elements with