Jump to content

Trouble with text-align-last


lhuxley

Recommended Posts

I am attempting to fine tune the formatting of an ePub document. For those unaware, eBook readers are essentially browsers. They depend on HTML and CSS like any web browser. The particular text that I'm working on is an old German book, that was set in Fraktur type. The combination of the large Fraktur type, long German words and the often narrow confines of an eBook reader can mean very few words per line of text.I am having trouble marking up lines of poetry so that they are layed out correctly on both narrow and wider screens. Obviously, each line of poetry should start on its own line, left justified, but a problem arises when a line is too long for the screen and needs to be wrapped. By default the text wraps to the left, but then it appears as a new line of poetry. A rather contrived example:Mary had a little LambHis Fleece was white asSnow(I've capitalized all of the nouns as in German, adding to the confusion.)The original typesetter solved the problem by right justifying the wrapped text. I have tried to duplicate the original format of the book using both of the following styles:text-align: justified;text-align-last: right;But then the unexpected (or unwanted) happens. On narrower screens, the short lines of poetry end up right justified. On wider screens all of the lines end up right justified.Am I doing it wrong, or is there some other way to approach this?

Link to comment
Share on other sites

If each line is in its own paragraph or if the lines are separated with <br> elements then text-align-last is going to force the last line of each section of text to be aligned to the right. If there is only one line, then it will be aligned to the right.

Link to comment
Share on other sites

If each line is in its own paragraph or if the lines are separated with <br> elements then text-align-last is going to force the last line of each section of text to be aligned to the right. If there is only one line, then it will be aligned to the right.

Yes, that appears to be exactly what is happening. text-align-last works fine if the paragraph is guaranteed to be at least as long as the available line length (box width). A more general (more useful?) implementation would only affect text that had been wrapped. In any case, as implemented text-align-last appears to be a dead end for formatting poetry.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...