[Resolved] Avoid post title breaking to one word in a new line

Home Forums Support Avoid post title breaking to one word in a new line

  • This topic has 3 replies, 2 voices, and was last updated 1 year ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1002316
    Ian

    Is it possible to make sure the post title (h1) does not break to a new line just for one word. I would like it to at least break to two words or more.

    #1002428
    David
    Staff
    Customer Support

    Hi there,

    it would probably require some Javascript to calculate there is an orphan word. But then what does it do with it – if it forces it to one line then that line would overflow the container, which wouldn’t be pretty.

    I did find this on StackOverflow which stops orphans by breaking the title into groups of words:

    https://stackoverflow.com/a/32895944

    The function call at the end of the code:

    noMoreLonelyWords("p", 3);

    Targets <p> tags and splits sentence into groups of 3 words. So switch the P to H1 and see how that works.

    #1002831
    Ian

    Thanks for that David, I’ll give that a go.

    #1002833
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.