Search code examples
phplaravellaravel-5.3laravel-blade

Showing whitespace from text (Laravel 5.3)


Users have been adding breaks for their paragraphs which can be seen in the database when looking at their text columns, like this:

enter image description here

However, when I display the text on their profile pages, like this:

<h5>{{ $user->description }}</h5>

The text simply displays as one large paragraph. I am looking to have the line breaks in the database show on the page to split up the paragraph.


Solution

  • This is most likely a CSS issue rather than a Laravel specific issue. You should try set that element to honor white-space:

    h5 {
        white-space: pre-wrap;
    }
    

    white-space: pre is also an option.

    You can see here for the variances between the white-space options: https://css-tricks.com/almanac/properties/w/whitespace/