Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 09-08-2025, 08:27 AM   #1
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 74
Karma: 10
Join Date: May 2025
Device: iPad
How to Set Link Color for Apple Books in Dark Mode?

I have an EPUB containing links which I wanna apply specific colors to. This works well for all e-readers I've tested so far, except for Apple Books which refuses to display any other color for links than the default blue.

The currently applied CSS rules are:

Code:
@media (prefers-color-scheme: dark) {
  a,
  a:link,
  a:visited,
  a:hover,
  a:focus,
  a:active {
                      color: #cc0000 !important;
    -webkit-text-fill-color: #cc0000 !important;
  }
}
And the HTML has the required Apple specific dark-mode class "ibooks-dark-theme-use-custom-text-color" set on the html-tag.

Does anybody know how to enforce Apple Books to style the links in dedicated colors?

I append an example ebook which as said works almost everywhere - but unfortunately only almost...
Attached Files
File Type: epub apple_books_dark_mode_link_test.epub (3.0 KB, 49 views)
Slevin#7 is offline   Reply With Quote
Old 09-09-2025, 07:28 PM   #2
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,857
Karma: 8821117
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
I have an EPUB containing links which I wanna apply specific colors to. This works well for all e-readers I've tested so far, except for Apple Books which refuses to display any other color for links than the default blue.

The currently applied CSS rules are:

Code:
@media (prefers-color-scheme: dark) {
  a,
  a:link,
  a:visited,
  a:hover,
  a:focus,
  a:active {
                      color: #cc0000 !important;
    -webkit-text-fill-color: #cc0000 !important;
  }
}
And the HTML has the required Apple specific dark-mode class "ibooks-dark-theme-use-custom-text-color" set on the html-tag.

Does anybody know how to enforce Apple Books to style the links in dedicated colors?

I append an example ebook which as said works almost everywhere - but unfortunately only almost...
You’ve run into one of the classic pain points of Apple Books: it ignores most css rules related to link colors in dark mode, even when you use !important. Apple enforces its own scheme to guarantee contrast and readability, and it often overrides anything declared in the epub.

What you already tried (color and -webkit-text-fill-color) works fine in most readers, but in iBooks this happens:

1) Apple Books applies its own theme depending on the user’s choice (Light / Sepia / Dark).

2) In dark mode, links are forced to blue for guaranteed contrast.

3) Even with the ibooks-dark-theme-use-custom-text-color class, only regular text can be customized, not links.

What you can try is to force fill on an inner span instead of <a>. Wrap the link text in a span and apply the color there. Something like:

1. In your .css stylesheet:

Code:
a {
  color: inherit !important;
  text-decoration: none !important;
}

@media (prefers-color-scheme: dark) {
  a > span {
    color: #cc0000 !important;
    -webkit-text-fill-color: #cc0000 !important;
    text-decoration: underline;
  }
}
2. In your .xhtml file:

Code:
<a href="your_ref_here.xhtml"><span>Go to Chapter 2</span></a>
This should work. Another thing you could try is to use the background-clip property, something like:

Code:
@media (prefers-color-scheme: dark) {
  a {
    color: inherit !important;               /* neutralize Apple's override */
    background: #cc0000 !important;          /* desired color */
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    text-decoration: underline;
  }
}
In this last case you don't need to enclose the text in a span tag. Try both methods.
RbnJrg is offline   Reply With Quote
Old 09-12-2025, 11:47 AM   #3
Slevin#7
Connoisseur
Slevin#7 began at the beginning.
 
Posts: 74
Karma: 10
Join Date: May 2025
Device: iPad
@RbnJrg, thanks for this comprehensive discription. Your first suggestion I've already tried - but didn't work. The second approach is kinda crazy shit I'd never come up by my own^^, thus big points for that - although, you can guess, unfortunately doesn't work as well.

So at this point I assume there is not much to do than to gratulate each and everyone of the e-readers to give their best in making beautiful books from a pain in the ass to just not doable. I mean, there is no big one who refuses to take part in being as annoying as can be. Google Play Books for example just doesn't let you set the text-color for dark mode, insiting to display an ungly gray.

And I could go on on all the others as well, it just woudn't help, so I'd spare my nerves and wish them all just roses....
Slevin#7 is offline   Reply With Quote
Old 09-12-2025, 12:03 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 80,212
Karma: 148951761
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
My solution is to not use Books for anything.
JSWolf is offline   Reply With Quote
Old 09-12-2025, 05:27 PM   #5
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,857
Karma: 8821117
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Slevin#7 View Post
@RbnJrg, thanks for this comprehensive discription. Your first suggestion I've already tried - but didn't work. The second approach is kinda crazy shit I'd never come up by my own^^, thus big points for that - although, you can guess, unfortunately doesn't work as well.
Indeed, Apple Books doesn't allow much flexibility in dark mode But do one last try; instead to apply a color do cheat and apply a gradient to the text. Of course, this gradient isn't actually a gradient, but a solid color. Use the following style:

Code:
@media (prefers-color-scheme: dark) {
    a,
    a:link,
    a:visited,
    a:hover,
    a:focus,
    a:active {
        background: linear-gradient(#cc0000, #cc0000) !important; 
        background: -webkit-linear-gradient(#cc0000, #cc0000) !important;
        background-clip: text !important;
        -webkit-background-clip: text !important;
        color: transparent !important;
        -webkit-text-fill-color: transparent !important;
    }
}
As you can see, the gradient is not such because the same color is used as stops.

Last edited by RbnJrg; 09-12-2025 at 05:29 PM.
RbnJrg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to automatically invert font color in dark mode davidhcje Viewer 3 04-26-2024 10:38 AM
Possible to invert image color in dark mode? davidhcje Viewer 4 05-18-2021 08:25 PM
How do I change the text color to accomodate dark mode? bookgobrrr Editor 8 09-26-2020 01:21 PM
Feature Request: Dark Mode menu color/border Katsunami Calibre 3 09-01-2020 05:18 PM
Scroll bar color is dark mode JSWolf Calibre 1 08-03-2020 06:01 AM


All times are GMT -4. The time now is 05:58 PM.


MobileRead.com is a privately owned, operated and funded community.