為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Can I set different link colors for pages with light and dark backgrounds?

  • 6 回覆
  • 0 有這個問題
  • 1 次檢視
  • 最近回覆由 Terry

more options

I use userChrome.css and userContent.css to (1) turn unvisited links bright red, and (2) turn visited links bright purple, and (3) add underlines to all links.

This works well on light backgrounds, makes links easy to see and easy to distinguish from other text, but makes them harder to see on pages with dark backgrounds.

Is there a way to vary the link color to improve contrast? I can't use the default colors because most sites use blue links which are hard to distinguish from black text.

I use userChrome.css and userContent.css to (1) turn unvisited links bright red, and (2) turn visited links bright purple, and (3) add underlines to all links. This works well on light backgrounds, makes links easy to see and easy to distinguish from other text, but makes them harder to see on pages with dark backgrounds. Is there a way to vary the link color to improve contrast? I can't use the default colors because most sites use blue links which are hard to distinguish from black text.

所有回覆 (6)

more options

P.S. I already use a 1 pixel blur-shadow to bolden all text on Firefox on Linux Mint. If it's possible to use 2 shadows, I could perhaps use a white 5 px blur behind links, with a font-colored 1 px blur on top of that, with the font on top as usual.

more options

Hi Marja, it depends. Some sites are themed based on a signal from the browser about whether you prefer a light or dark theme. This would be one way to decide what text/background colors to apply to links. More info: https://developer.mozilla.org/docs/Web/CSS/@media/prefers-color-scheme

But some sites use a dark or light theme regardless of your browser's expressed preference, so in that case, you would need a script that can detect the appearance of the page in order to choose the best color scheme.

Are you currently using text-shadow? You can layer shadows starting from different positions, but it still has some transparency so this isn't very nice:

text-shadow: #eee -10px -5px 20px, #eee 10px 5px 20px, #eee -10px 5px 20px, #eee 10px -5px 20px;

Although it gives the link a crude appearance, what about a simple background color?

background-color: #ffe !important; border-radius: 4px;

Hopefully that won't be too blinding on dark-themed sites.

more options

There is text-shadow and box shadow that supports multiple colors apart from an outline, so you can possibly use a set for dark and white.

I'm not sure what is best in your case, so my try at subreddit FirefoxCSS.

more options

Note that websites can use an image as a clickable link (i.e. no text), so be cautious with using !important to override background-color as this can cause images to disappear.

more options

Thanks. I've tried the background color. It's a bit too intense. I think something which halfway lightens the backgrounds might work better.

more options

There's a user script called NoBrighter on greasyfork .org which may suit you. It is very simple to configure.