Front-end education for the real world. Since 2018.





Create a line break while maintaining inline status

Andy Bell

Topic: CSS

Sometimes you want to create a line break after an inline element, while retaining that inline element’s inline status. Luckily all it takes is a little pseudo-element magic:

Code language
css

.inline-element::after {
  content: '\A';
  white-space: pre;
}

This is especially useful in <form> contexts, like the following example shows.

Enjoyed this article? You can support us by leaving a tip via Open Collective


Newsletter