Donny P Donny P - 1 month ago 7
CSS Question

Prevent text wrapping within an element

How can you force text within an element to not wrap, and have the element's width still determined by its contents (instead of manually setting width)?

Example:

On this page you can see a green button with the text "Get Started". For smaller screen sizes, the text wraps. How can I prevent this?

https://pleth-test.herokuapp.com/

I tried using

overflow
and
text-wrap
CSS properties, but couldn't get anything to work.

Answer

Add this to your css:

white-space: nowrap;
Comments