The Design and Construction of eBooks, by Steve Thomas

Poetry

Poetry presents some unique problems, with short, sometimes indented lines, with the whole centered on a page without the actual lines being centered. Somewhat like this:

I must go down to the sea again,

To the lonely sea and sky

I left my shirt and socks there;

I wonder if they’re dry?

Spike Milligan

An early approach to verse, and one I still see occasionally today, was to use the PRE tag. The results are quite ordinary:

        I must go down to the sea again,
          To the lonely sea and sky
        I left my shirt and socks there;
          I wonder if they’re dry?

Better is to define a class for verse, which gives us greater control over formatting: basically verse needs to be left justified and indented:

div.stanza {
    margin:1em auto;
    width:70%;
    }
div.stanza p {
    margin-left:2em;
    text-align:left;
    text-indent:-2em;
    }

This wraps each verse (or stanza) in a div, defining a width of 70% of the body, while the margin auto declares equal margins left and right. The second line causes any line which is too long to fit to wrap to the next line and indent. The 70% width is “about right” for many poems, but if the lines are short we can adjust that to compensate so that the verse is more centered on the page.

I must go down to the sea again,

To the lonely sea and sky

I left my shirt and socks there;

I wonder if they’re dry?

 

For longer poems, it is sometimes useful to include line numbers (usually only every fifth or tenth line). This will push them unobtrusively to the right margin:

.ln {
    color:gray;
    float:right;
    font-style:italic;
    font-size:.8em;
    margin:0 -2em 0 1em;
    text-align:right;
    text-indent:0;
}

She left the web, she left the loom,

She made three paces thro’ the room,

She saw the water-lily bloom,

She saw the helmet and the plume,40

She look’d down to Camelot.

Out flew the web and floated wide;

The mirror crack’d from side to side;

“The curse is come upon me,” cried

The Lady of Shalott.

https://ebooks.adelaide.edu.au/about/part2.7.html

Last updated Tuesday, January 26, 2016 at 23:27