09-29-2020, 09:55 PM | #1 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Colored Text, EPUB, Android Dark Mode
The CSS in my EPUB has a class where the color of the text is specified. I then use "<span class="xyz">abc</span>" to define which parts of the text I want highlighted by that color. The problem is that many EPUB readers actually seem to override the font specifications. Is there a way for me to force the reader to use my font specification?
|
09-29-2020, 11:58 PM | #2 | |
Bibliophagist
Posts: 40,430
Karma: 156982136
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
|
|
Advert | |
|
09-30-2020, 12:01 AM | #3 |
A Hairy Wizard
Posts: 3,219
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
edit: Dang-it, ninja'd again!!
Some readers/devices think they know better how to display a book than the publishers that created them. Unfortunately, a lot of publishers prove them right... Also, there are many devices that simply can't display color - like eink... Some of those readers/apps have the option to view in "publisher's mode", but that would require the user to select that option. Apart from that, you can't really "force" the reader to follow your css. The best you can do is keep your css as simple as possible.... and possibly use media queries to determine how to style your spans.... a color display that is friendly to publisher's css => colored font; an older eink display => might need to be highlighted with an <em> tag with bold and/or italic styling. |
09-30-2020, 12:32 AM | #4 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Quote:
|
|
09-30-2020, 12:36 AM | #5 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Quote:
|
|
Advert | |
|
09-30-2020, 01:40 AM | #6 |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Using <a> instead of <span>
If I tag a segment of text as a link, most of the EPUB readers will make that text a different color (usually blue) and underline it. But the opening tag has to be <a href="xyz">. If the href is left out, then most readers will simply disregard the <a> tag and the text will be styled as with any text. If I set the href to null, meaning: <a href="">, then the readers will style the text as blue and underline it but then display an error when the link is clicked on.
Is there a way for the href to end up refering to that segment of text? It would be a complicated way of adding color to text but since there is no way at this point to get most EPUB readers to respect the css styling, this might be one work around. |
09-30-2020, 10:27 AM | #7 |
mostly an observer
Posts: 1,515
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
|
09-30-2020, 11:45 AM | #8 | |
A Hairy Wizard
Posts: 3,219
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
The <em> tag is specifically designated for text that needs to be emphasized. If you don't define the styling you want for <em> it usually defaults to italics but you can designate the style however you want. eg em {color:red; text-decoration:underline} If the device you are using doesn't respect the publisher's CSS then you could try giving in-line styling *shudder* eg <p>This sentence contains an <em style="color:blue">emphasized</em> word.</p> That doesn't help with non-color displays....so, again, your best bet is to try media queries. Then you can have stuff like: If this device is an eink: em {font-weight:bold} If this device isn't an eink, but can't display color: em {font-style:italic} all other devices: em {color:blue} with: <p>This sentence contains an <em>emphasized</em> word.</p> note: that is not the proper syntax for media queries...just giving the idea...but you can learn a little bit more about how to do them at the W3Schools website. There is also a Sigil plugin, AddKindleMediaQueries that will add some code to get you started with kindle devices...you will need to figure out the other devices on your own. Cheers, Last edited by Turtle91; 09-30-2020 at 11:50 AM. |
|
09-30-2020, 11:56 AM | #9 | |
Well trained by Cats
Posts: 30,441
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
Your idea of using a Link styling has merit for COLOR displays. eg. Code:
<style> a:link { color: green; background-color: transparent; text-decoration: none; } a:visited { color: pink; background-color: transparent; text-decoration: none; } a:hover { color: red; background-color: transparent; text-decoration: underline; } a:active { color: yellow; background-color: transparent; text-decoration: underline; } </style> |
|
09-30-2020, 08:36 PM | #10 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Quote:
Without the styling, the final outcome can look very bad, almost unreadable at times. With the proliferation of OLED display cellphones, more and more people are using eReaders on their phones because Dark Mode display, which greatly reduces the phone's energy consumption, affords them hours of reading on a device they already have without having to purchase or carry around another one. The problem is that many of these eReaders will simply disregard CSS, because Dark Mode does require the phone to set its own color scheme, and anyone that relies on CSS to style their work runs the risk of creating the impression among their readers that their work is inferior. I have found that only the <em> and <i> tags for italics and <strong> and <b> tags for bold are reliably rendered. The <a> tag is also reliable in that it will almost definitely be underlined and possibly made blue if the eReader can display color. But the problem with using the <a> tag is getting the href to refer back to the text that was highlighted as I mentioned above. The underlying philosophy of what I am trying to do is simply to get to lowest common denominator and create documents that will display the same regardless of eReader. |
|
09-30-2020, 08:45 PM | #11 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Quote:
|
|
09-30-2020, 10:46 PM | #12 | ||||
Wizard
Posts: 2,303
Karma: 12126963
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
What's the ultimate goal here? Can you show us an example picture of a document and what you're trying to achieve? Quote:
If underlining is what you want, that would achieve it. And every single reader/browser in the world would display an underline: Code:
<p>This is a sentence with <u>underlined</u> text.</p> Quote:
If you're having trouble getting basic HTML links to work, I believe you're trying to jump too far into the complicated deep-end. I would highly recommend learning some more of the basics of HTML first:
Here's an example I wrote last year about <a>: Post #3 in "hyperlink endnotes" I even color coded the parts of a link red+blue in order to explain easier. Quote:
Follow the standards, code your book properly, and then if the user wants to use some crappy CSS-overriding-reader like Moon+, then that's on them. |
||||
10-01-2020, 04:44 AM | #13 | |
Junior Member
Posts: 8
Karma: 10
Join Date: Sep 2020
Device: none
|
Quote:
The problem is this: with the proliferation and increasing popularity of cell phone based eReaders, in particular with the advent of OLED enabled Dark Mode, more and more eBooks are being consumed by readers using their mobile phones. Some eReaders like Moon+Reader will repect CSS styling whereas other eReaders like Prestigo will not. There are many reasons to choose one eReader over another and no one app can be said to dominate the space. Prestigo for instance offers text-to-speech for free whereas one would have to pay for it in Moon+Reader. Because of the heterogeneity of the eReader space, the final product which the reader experiences can be somewhat unpredictable; particularly if one uses CSS. To be absolutely certain that the final product looks similar regardless of the device used to render it, creators of eBooks are left with only the most basic tools like <b>, <i> and <u>. Unlike the style sheets which some eReaders will disregard, all eReaders I have looked it seem to respect these basic tags. Meaning that if you style your work only with these tags, it should then look more or less the same agnostic of the viewing device. I say more or less because aside from ignoring the document styling, some eReaders will force their own styling like increasing the line spacing. This brings me to my interest in the <a> tag. All eReaders that can display color which I have looked at will display a link as blue and all eReaders will underline a link. This means that the creator of a book can, in a somewhat sneaky way, trick the eReader into displaying text color other than say white font on black. If it can be made to work, this is a way of grabbing back some control. |
|
10-01-2020, 01:43 PM | #14 | ||||
Wizard
Posts: 2,303
Karma: 12126963
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
If you want an Android reader that follows the EPUB standards (plus free TTS), use PocketBook Reader or Gitden. A lot of this was written about in last year's topic: "Epub-problems in tablets". Quote:
See this ebookcraft 2019 talk, "Building Ebooks that Last". She worked as an editor at Houghton Mifflin for many years, and explains why it's best to use proper markup + follow the standards. Around 19 minutes in, she even shows a recipe book split from its CSS, and shows the differences between a mess (using <p class="heading1">), and a properly marked HTML document (using <h1>). Quote:
Yes, you may even need to code some fallbacks for common use-cases/edge-cases, for example: but you can only go so far. If the ebook works properly on Kobo/B&N/Apple/Amazon (all the mainstream stores/readers), you'll be fine. If the reader still insists on using a program that disregards/overrides everything (like Moon+)... then that's not on you. Quote:
HTML tags ARE NOT meant "for looks", they're meant to mark PURPOSE (semantics):
Most browsers display that way by default, but lots of non-visible information gets carried over as well. For example:
Proper <table> + <th> + <td> markup allows: Code:
Name | Eggs | Bread ____________________ Joe | 2 | 2 Smith| 1 | 0 "Name: Joe, Eggs: 2, Bread: 2" "Name: Smith, Eggs: 1, Bread: 0" not: "Name Eggs Bread. Joe, 2, 2. Smith, 1, 0." Wrong/Poor markup has been written about many, many times over the years. Here's a few of the latest: And if you want to see what detrimental effects junk markup can do, see this talk given by a blind person: ebookcraft 2019, "The User's Perspective: Accessibility Features in Action". Last edited by Tex2002ans; 10-01-2020 at 02:16 PM. |
||||
10-01-2020, 02:52 PM | #15 |
Grand Sorcerer
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Therein lies a big part of the problem. You can't be absolutely certain in all cases.
Last edited by DiapDealer; 10-01-2020 at 02:55 PM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I change the text color to accomodate dark mode? | bookgobrrr | Editor | 8 | 09-26-2020 02:21 PM |
ePub color text on night mode on iPad | larysa | Apple Devices | 1 | 11-29-2017 06:54 AM |
Removing colored text | jkrzok | Calibre | 2 | 07-09-2015 02:40 PM |
Colored text in Marvin | The Old Man | Marvin | 3 | 01-19-2014 11:43 AM |
Colored text in books | isotherm | Amazon Kindle | 1 | 09-18-2010 09:51 PM |