Open Bug 1790109 Opened 2 years ago Updated 6 months ago

link rel="favicon" media attribute / query not working

Categories

(Firefox :: General, defect, P3)

Firefox 104
defect

Tracking

()

People

(Reporter: iipandarx, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0

Steps to reproduce:

I tried to use different favicons for dark and light mode using the media attribute and prefers-color-scheme, the exact same code works in latest Chrome

Code:
<link href="/favicon-light.png" rel="icon" media="(prefers-color-scheme: dark)" type="image/png">
<link href="/favicon-dark.png" rel="icon" media="(prefers-color-scheme: light)" type="image/png">

Actual results:

The favicon that is first in the markup is used, disregarding the media attribute

Expected results:

It should use different favicons based on the preferred color scheme

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: Playback' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core
Component: Audio/Video: Playback → DOM: Core & HTML
Component: DOM: Core & HTML → General
Product: Core → Toolkit
Product: Toolkit → Firefox
Blocks: dark-mode
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
See Also: → 1603885
Summary: link rel="favicon" media attribute not working → link rel="favicon" media attribute / query not working
Duplicate of this bug: 1838175
Duplicate of this bug: 1862015

FWIW comment 0 is not great, because the prefers-color-scheme value for websites and for the browser theme might not be the same.

Instead, the right way to create a favicon would be to e.g., use an svg that handled prefers-color-scheme internally. If you need PNGs or so you could probably use an <svg:image> (though I haven't tested this). That would actually work with all different combinations of themes and user preferences.

You need to log in before you can comment on or make changes to this bug.