Because you made three words into one word by using nonbreaking spaces and therefore the browser has no clue where to break the sentence apart from the letters that don’t fit.
<h1>Save energy with efficient Swimming Pool Pumps</h1>
I’m guessing the author wanted those three words to break to a new line together but didn’t think of smaller screens. You would probably be better putting ‘swimming pool pumps’ inside a span and then set the span to display:block to keep it on a new line.
If you then remove the non breaking spaces and replace them with normal spaces then the words will wrap correctly.
Hi @konradvg
In this case I think it could also be solved by inserting the <wbr> element in the html. It acts as a marker for wordbreaks but doesn’t introduce a hyphen and is a zero length.
E.g: <h1>Save energy with efficient Swimming <wbr>Pool <wbr>Pumps</h1>
lol - I think that by adding the wbr tag you are in fact doing exactly the same as this:
<h1>Save energy with efficient Swimming Pool Pumps</h1>
I’m guessing that “swimming pool pumps” should initially wrap as a block to the new line or indeed start on a new line to begin with.
If the viewport is narrower than the width of the text then the words should be allowed to wrap individually which is what will happen with a span set to display:block.
e.g.
<h1>Save energy with efficient <span>Swimming Pool Pumps</span></h1>
h1 span{display:block}
Of course it does depend on what the authors intentions were
I’ve done similar things before, only setting the span to display: inline-block. This lets it appear as one line on a big screen, but when it wraps on smaller screens, you control where the break occurs. It can prevent the last word getting orphaned on the new line.
Thanks folks for all your input and apologies for the late reply - holidays!
I appreciate your workarounds etc but the issue isn’t that I (or the author) wanted certain words to be placed together on the same line, we’re happy for the browser width to determine how the text flows. But obviously not break mid word…
The strange thing is that when I look in the WP admin and change to source for that text area I cannot see any of the characters you discovered. See screenshot below:
I always run my copy through TextEdit to clean it up so don’t understand where these have come from? But the main thing is I can’t see them so can’t see how to remove them?
Sorry, I don’t know anything about WP so can’t really help. Don’t you have an option to turn on invisible characters?
You can see the non breaking spaces in the chrome web inspector on the live version so I guess you could just look through the pages and see where they were and then go back and edit those sentences. (I looked through a couple of pages and didn’t notice any others though.)