How to format text with nl2br

How can I format a text field from a database with nl2br()?

You can:

  • Put your text in a <pre> tag
  • Do this using CSS with the white-space: pre; property. Example: .mytext { white-space: pre; }
4 Likes

I try to do this but dont work as expected.

When you save your document it auto format the document and the TABS create spaces .

FINAL DISPLAY

if I add the pre tag

 <div class="container-xl pt-5">
                    <div class="row">
                        <div class="col-9 offset-2">
                            <div class="txt-tittle txt-white">
                                <pre> Negocios en crecimiento
                                   para hoteles
                                   y
                                   sus socios</pre>
                            </div>
                            <div>
                                <a class="link-green-round" is="dmx-link" href="">Leer Más</a>
                            </div>
                        </div>

                    </div>
                </div>

display like this

Any help??