04-18-2024, 07:49 AM | #1 |
Connoisseur
Posts: 74
Karma: 6698
Join Date: Sep 2022
Location: South Africa
Device: kindle pw10
|
css question
Is it possible to include a text string into a css property?
For example: p.break { text-align: center; text: "this is a break"; } Then use: <p class="break"></p> Thanks |
04-18-2024, 08:12 AM | #2 | |
Resident Curmudgeon
Posts: 76,368
Karma: 136466962
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
Code:
/* This is a break */ p.break { text-align: center; text-indent: 0; } |
|
Advert | |
|
04-18-2024, 09:12 AM | #3 | |
Not Quite Dead
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
Yes, it is possible to use CSS to insert text into content. Use a pseudo-element.
Example: Quote:
Last edited by Brett Merkey; 04-18-2024 at 09:14 AM. |
|
04-18-2024, 09:48 AM | #4 | |
the rook, bossing Never.
Posts: 12,342
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
I've never seen it used in actual ebooks. What happens if Amazon converts the epub? What does Calibre do on conversion to LRF, PDB, mobi/KF7, azw3/kf8? Logically the css should work like a macro and the conversion have the content text where the class is invoked. But macros are one of the evil things in C and C++ with sometimes unexpected expansion. Unavoidable in Assembler. |
|
04-18-2024, 11:04 AM | #5 |
Well trained by Cats
Posts: 30,442
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I agree with @quoth.
Just because CSS allows way more features , becaue. it was set for WEB pages. An e-book only uses a small subset. Even then, the 'we know better' folk that outfitted you device, chose to ignore, or took the code easy way out (User adjustable WITH Publishers settings being Algebraic) (and Posters, please verify your general comments on coding are generally Industry supported on mainstream e-readers ) |
Advert | |
|
04-18-2024, 03:08 PM | #6 | |
the rook, bossing Never.
Posts: 12,342
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
It works on everything. |
|
04-18-2024, 03:28 PM | #7 |
Bibliophagist
Posts: 40,475
Karma: 156982136
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
I read it as the OP wanted to be able to have the text displayed at the scene break specified in the stylesheet. I've seen this done with some image based scene breaks.
|
04-18-2024, 05:09 PM | #8 |
Well trained by Cats
Posts: 30,442
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
04-18-2024, 05:39 PM | #9 |
Zealot
Posts: 148
Karma: 1451628
Join Date: Jul 2021
Device: N/A
|
|
04-18-2024, 06:08 PM | #10 | |
the rook, bossing Never.
Posts: 12,342
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
I'd just put the actual text in the p tags, but I don't do that kind of ebook editing. |
|
04-18-2024, 07:51 PM | #11 | |
Zealot
Posts: 148
Karma: 1451628
Join Date: Jul 2021
Device: N/A
|
Quote:
The restriction Theducks gave may nevertheless point to a serious problem, in case it isn't recognized by parts of the eReaders, It is still to be tested on more devices :-). BTW, this feature survives to a conversion epub -> azw3 or pdf (using calibre). |
|
04-18-2024, 08:27 PM | #12 |
Not Quite Dead
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
|
"...may be very interesting for all type of repeated features"
It certainly is. However, it is specially convenient in dealing with books that use whitespace alone for scene breaks. Whitespace is an irritating waste of space for me. The method of pseudo-elements can add a visual break without touching the HTML code or even altering the original CSS. This is easy when the whitespace is produced by adding space to any paragraph above or below where the break is wanted. Style a pseudo-element version of that paragraph and you are done. Presumably the original code will serve as a fallback if that is relevant. I've used the method only on Amazon and Samsung products for about 12 years so I do not know that range of support beyond that. Last edited by Brett Merkey; 04-18-2024 at 08:40 PM. |
04-18-2024, 09:26 PM | #13 | |
the rook, bossing Never.
Posts: 12,342
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
Also in the source wordprocessing each kind of scene break indication can have a different style. That will map 1:1 to CSS and HTML. You are right that white space scene breaks don't work as well in ebooks, especially on phone screens, where most are read. There is zero need to utilize CSS as macros to insert content. It's actually more complicated and no easier to maintain and harder to generate. It's for web page server side programming, which I've done, never for ebooks. |
|
04-18-2024, 09:34 PM | #14 | ||
the rook, bossing Never.
Posts: 12,342
Karma: 92073397
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Quote:
There is no "Samsung" ebook platform. Quote:
There are many articles explaining why ebooks shouldn't slavishly copy printed books, especially novels. Replace white-space only scene breaks in the source is trivial as is reducing excessive white space that might be fine on a 9" hardback but not in an ebook. |
||
04-19-2024, 01:45 AM | #15 |
Connoisseur
Posts: 74
Karma: 6698
Join Date: Sep 2022
Location: South Africa
Device: kindle pw10
|
Thanks to all for the comments and interesting discussion. Will try the suggestions later when back from work.
Thanks again. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A CSS question | Woodssi | Sigil | 4 | 01-18-2022 09:36 PM |
css question | ralphiedee | Sigil | 74 | 12-23-2012 07:29 AM |
CSS Question | jackibar | Sigil | 24 | 03-01-2012 10:12 AM |
CSS question | crutledge | Workshop | 17 | 12-17-2011 08:52 AM |
CSS Question | AppleTard | Calibre | 1 | 06-12-2011 01:07 AM |