
Ian M. answered 05/16/19
Professional Web Designer, Developer, UI/UX
This is a very common problem, not just for your use case but also when displaying long URLs that will overflow your containers. Here are my possible solutions, from easiest to most complex:
1)
The simplest solution is to use wbr tags: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr. These are optional word breaks in HTML.
2)
I've also tried to tackle this problem with spans, although its being unsemantic feels a bit icky. Wrap your lines of text in spans then control the white-space property in CSS. Use white-space: nowrap; on the spans themselves. Each span will stay intact and line breaks will only happen between them.
3)
If you want to play with a responsive font size, you can use viewport units.
I hope this helps!
Ian