Skip to main content
Inspiring
September 19, 2022
Answered

Best practice for creating the lines above add below the text for export to epub

  • September 19, 2022
  • 2 replies
  • 1909 views

I need to create these lines above and below a chapter title in ID. I can create a simple underline UNDERNEATH the text but what about above it? Once done corrdctly I have to export the doc as an epub and want to make sure there is good spacing.

 

Correct answer James Gifford—NitroPress

Here is the css for that style as it is

p.Main-Title-Border {
border-color:#5780ca;
border-style:solid;
border-width:1px 0px 1px 0px;
color:#00aeef;
font-family:"Minion Pro", serif;
font-size:2.25em;
font-style:normal;
font-variant:normal;
font-weight:normal;
line-height:1.2;
margin-bottom:0;
margin-left:0;
margin-right:0;
margin-top:0;
orphans:1;
page-break-after:auto;
page-break-before:auto;
text-align:center;
text-decoration:none;
text-indent:0;
text-transform:none;
widows:1;
}
 
If I ADD the rules you posted the width of the line does not change
 
p.STYLENAME {
border-top: solid 2px black;
border-bottom: solid 2px black;
padding-top: 10px;
padding-bottom: 10px;
}

Ha.

 

Add the parameter "width: min-content;" to the CSS definition. This does not work in Kindle (my usual end point) but does work in my two primary test EPUB readers.

 

(EPUB is secondary for me, so if it doesn't work in Kindle, I tend to forget about it.)

 

And if you want some slight extension of the lines beyond the text, add small amounts of left and right padding.

 

2 replies

BobLevine
Community Expert
Community Expert
September 19, 2022

Assuming that's a single paragraph, use the rule above and the rule below in the paragraph style definition.

Inspiring
September 19, 2022

Added rules looks great but does NOT export to epub. I had an underline BEFORE adding the rules. I removed underline and added the two rules but it does not export to epub Reflowable

?????

James Gifford—NitroPress
Legend
September 19, 2022

Curious...why define it as a p with a class when you could use h1 since it's a chapter heading only?


Because everything is defined as p. by default unless you reassign it in the export menu. I doubt that's been done here. (It is a good idea, to impose HTML structure on the export, for accessiblity and other reasons. But keeping it simple here.)

 

Willi Adelberger
Community Expert
Community Expert
September 19, 2022

Some Possibilities in Paragraph Styles:

  • Paragraph Frame
  • Rulers abover and below