

It adds white-space and two additional properties: overflow and text-overflow. Here, you have set white-space to nowrap, which will prevent all line breaks. The white-space property has numerous options, all of which define how to treat white space inside a given element. sammy-wrap but now you add another property: white-space. This means it will break lines in the default manner. This class will create a visual box, but it does not define any special wrapping properties. It defines six common CSS properties including border-radius, background-color, border max-width, padding, and margin-bottom. Each one will handle line breaks differently: the first will break text in the default manner while the second and third will force the text not to create a newline and break.įirst, create and open a new file called main.css using nano or your preferred editor:Īdd the following content, which will introduce three CSS classes that use several properties, including white-space: In this step, you will create a style sheet with three different classes. Step 1 - Preventing and Forcing Line Breaks in CSS You can view our tutorial series How To Build a Website with HTML for an introduction. A code editor of your choice, such as nano or Visual Studio Code.To complete this tutorial, you will need: This will provide you several options for wrapping or not wrapping your text. Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio. Indian mul mora cisco masu salmon, roosterfish requiem shark longnose lancetfish bluefish red snapper Sacramento splittail giant danio. Medusafish banded killifish convict blenny saury threadsail beluga sturgeon. In this tutorial, you will style the same block of text four different ways, first with line breaks and then three times without line breaks: You can prevent line breaks and text wrapping for specific elements using the CSS white-space property. But there are times when you want blocks of text to stay on the same line, regardless of length. Text wrapping can also prevent horizontal scrolling.

Wrapping constrains text in one way or another and prevents design issues.

Developers typically like to wrap text on a web page.
