Novel formatting

I have decided to share the code that I used on my ‘prose’ pages so that others can easily create nicely formatted pages set as they would be in a novel. The first line of a paragraph following a h1 tag has a large first letter.

Subsequent lines use standard paragraph tags and begin with an indented first line. Where those paragraphs wrap, lines are not indented, however if you want to start a new scene you insert a paragraph with the class ‘space’. Space forces a 1em height line in between, and the paragraph following it has no indent.

 

It’s entirely up to you whether you want to put an   element inside the paragraph to make sure the height shows, but I have overridden the height of the empty paragraph in the CSS.

Part of the style prevents the user from selecting the text. This is an entirely optional feature — to disable it, simply remove the first instance of the .prose class that contains the -webkit-touch-callout and -user-select properties.

 

CSS

 

/* prose pages */
/* Fonts are set on the container and header in case a theme likes to override h1 styles. */
.prose {-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}
.prose {font-family: 'EB Garamond', serif; margin-left: auto; margin-right: auto; max-width: 608px;}
    .prose h1 {font-family: 'EB Garamond', serif;text-align:center !important;margin-bottom: 70px; margin-top: 70px;}
    /* Justify makes the line spread to the full width. Wordpress makes this even nicer by using automatic line hyphenation. */
    .prose p {margin:0;text-align:justify}
    .prose p.space{min-height:1em;}
    .prose p + p {text-indent: 28.8px;}
    /* Use .pov where you want to put *** or another marker centred between sections. */
    .prose p.pov {text-align:center;}
    /* Force the lines following a .pov or .space to be non-indented. .first enables you to force this on a specific line with no prior space */
    .prose p.first, .prose p.pov, .prose p.pov + p, .prose p.space + p {text-indent:0;}
    .prose h1 + p::first-letter {float: left;font-size: 62px;line-height: 2.8;margin-right: 4px;margin-top: 7px;}

 

HTML

 


<article class="prose">
   <h1>Chapter 1</h1>
   <p>This is the beginning of a chapter. The first letter is taken from the style where the line following the chapter heading is a paragraph.</p>
   <p>Subsequent lines use standard paragraph tags and begin with an indented first line. Subsequent lines are not indented, however if you want to start a new scene you insert a paragraph with the class ‘space’. Space forces a 1em height line in between, and the line following it has no indent.</p>
   <p class="space"> </p>
   <p>It’s entirely up to you whether you want to put an &nbsp element inside the paragraph to make sure the height shows, but I have overridden the height of the empty paragraph in the CSS.</p>
</article>

Previous Post Next Post