View Single Post
Old 03-09-2019, 06:49 AM   #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,799
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by AlexBell View Post
I'm working on an epub ebook which in each of its 18 books and 208 chapters has a 'preface' of several words or a few sentences. The text of the 'preface' is centered, often using several lines, and quite often the last word on a line breaks, and is hyphenated. I think this looks awful.

Is there a way to prevent all of the words in the centered text from breaking? A word at the end of a line which would otherwise break will then drop to the next line.

I know how to prevent a single word from breaking and hyphenating. But I really don't want to have to apply this markup to all or most of the words in each of the 226 'prefaces'.
In your .css file create the following class:

Code:
.no_hyphens {
    adobe-hyphenate: none;
    hyphenate: none;
    hyphens: none;
    -epub-hyphens: none;
    -moz-hyphens: none;
    -webkit-hyphens: none;
}
And in your .xhtml file you have two ways of working:

1) Enclose the text to be not hyphened in a div tag with the class previously defined; i.e:

Code:
<div class="no_hyphens">
  <p>blah, blah, blah...</p>

  <p>blah, blah, blah...</p>

  <p>blah, blah, blah...</p>
</div>
2) If you want to apply the style to only a tag (i.e. h1, h2, h3..., p, etc.) then give the style to that tag; i.e;

if you have:

Code:
<h2 class="title">This is my own title</h2>
then after applying the new style you'll have:

Code:
<h2 class="title no_hyphens">This is my own title</h2>
Or if you have:

Code:
<p class="center">The text of my preface here....</p>
then after applying the new style you'll have:

Code:
<p class="center no_hyphens">The text of my preface here....</p>
Regards
Rubén
RbnJrg is offline   Reply With Quote