In web design, breaking lines at the right place is crucial for readability and layout. While HTML provides some basic line break tools, CSS offers powerful ways to control line wrapping and force or prevent line breaks.
In this blog, we’ll explore the different methods to break a line using CSS and best practices for clean, responsive design.
✅ Method 1: Use the HTML <br>
Tag (Not CSS but Common)
Though not a CSS method, it’s important to know:
<p>This is line one.<br>This is line two.</p>
Use
<br>
sparingly—mainly for poetry, addresses, or inside form labels.
✅ Method 2: Force Line Break Using white-space
You can control whether text wraps or not using the white-space
property.
🔹 CSS:
.break-text {
white-space: normal; /* Allows line breaks */
}
Other common values:
nowrap
– Prevents line breakspre
– Preserves spaces and line breakspre-line
– Preserves line breaks, collapses extra spaces
✅ Method 3: Allow Long Words to Break – word-break
and overflow-wrap
Sometimes, long words or URLs break the layout. CSS can fix this.
🔹 CSS:
.break-word {
word-break: break-word;
overflow-wrap: break-word;
}
This ensures long content like emails or URLs wraps instead of overflowing.
✅ Method 4: Line Break After or Before Elements Using display
You can force an element to break the line by changing its display property.
🔹 CSS:
.break-block {
display: block;
}
For example:
<span class="break-block">Line 1</span>
<span>Line 2</span>
✅ Method 5: Insert Line Breaks With Pseudo-elements
For visual or decorative breaks:
.insert-break::after {
content: "\A"; /* Line break */
white-space: pre;
}
Note: Works best with inline elements and pseudo-elements like
::after
.
✅ Summary
Goal | CSS Property/Method |
---|---|
Break text naturally | white-space: normal |
Prevent text from breaking | white-space: nowrap |
Allow breaking of long words | word-break: break-word |
Break lines visually | display: block or ::after |
Manual line break in HTML | <br> tag |
Conclusion
Line breaks may seem simple, but controlling them precisely can dramatically improve readability and layout. With the right CSS properties like white-space
, word-break
, and display
, you can manage how and where text breaks—ensuring your designs look great on all screen sizes.