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: 73
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, 42 views)
Slevin#7 is offline   Reply With Quote
Old Yesterday, 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,853
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
Advert
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 08:34 AM.


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