Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<link rel="icon"> with media #6408

Closed
cawa-93 opened this issue Feb 22, 2021 · 5 comments
Closed

<link rel="icon"> with media #6408

cawa-93 opened this issue Feb 22, 2021 · 5 comments

Comments

@cawa-93
Copy link

cawa-93 commented Feb 22, 2021

Good day. My question: Is it allowed to use a media attribute with <link rel="icon"> like it is allowed to <link rel="stylesheet">? I could not find any information on whether this is allowed or not.

I tried customizing the icon depending on the browser theme:

    <link
      rel="icon"
      href="https://fakeimg.pl/128x128/000000/"
      media="(prefers-color-scheme: dark)"
      type="image/png"
    />

    <link
      rel="icon"
      href="https://fakeimg.pl/128x128/ffffff/"
      media="(prefers-color-scheme: light)"
      type="image/png"
    />

But in Firefox and Edge, the last icon is always taken, not the one that corresponds to the theme. And I can't understand:
The combination of rel="icon" and the media is not allowed by the standard, or standard allowed but browsers do not handle this scenario?

@Stivvv18
Copy link

Stivvv18 commented Feb 22, 2021 via email

@domenic
Copy link
Member

domenic commented Feb 22, 2021

The specification requires that media be respected for all link types, and for rel="icon" link types in particular it says:

Icons could be auditory icons, visual icons, or other kinds of icons. If multiple icons are provided, the user agent must select the most appropriate icon according to the type, media, and sizes attributes.

I wonder if other media queries (not light/dark mode) work. It's possible since those are somewhat recent, they are not fully hooked up to link elements.

@cawa-93
Copy link
Author

cawa-93 commented Feb 22, 2021

I wonder if other media queries (not light/dark mode) work. It's possible since those are somewhat recent, they are not fully hooked up to link elements.

It doesn't seem to work for any media queries. Try the demo

@domenic
Copy link
Member

domenic commented Feb 25, 2021

It looks like this is a known and acknowledged browser bug, at least for Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=970159 . Please go star that bug!

I'd suggest searching for similar issues for Firefox and Safari, and filing them if they don't exist.

I'll close this since I think the spec is in a good state here, although perhaps if no implementers are interested in this then we should reopen and change the spec to specifically exclude rel=icon. That would be a sad outcome, so hopefully we won't go there...

@beaufortfrancois
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants