0

I'm trying to break a line but it's always displayed whatever I do so I guess I'm doing something wrong. Here is my line from my php file

But it's displayed like this :

My site is designed to help content creators on the web, create a free account and start \nmaking money now.

Can you help me please ?

  • `\n` only turns into a newline for strings using `"`. For example: `"This has a newline at the end.\n"` and `'This doesn't have a newline at the end.\n'`. – IGP May 15 '21 at 23:32
  • Okay I did this and the balise isn't displayed anymore but it's not starting a new line. The line just continue as if there was no \n . – Jean Denis May 15 '21 at 23:55
  • Have you tried replacing your `\n` with a `
    ` tag? `{!! !!}` does not escape html, so that will force a line break.
    – IGP May 16 '21 at 00:09
  • Actually ```\n``` disappeared but ```{!! !!}``` are still displayed – Jean Denis May 16 '21 at 00:32
  • The `{!! !!}` would be used when displaying the variable on the page (assuming this is in a blade file), not as part of the string. (e.g., `{!! $subtitle_welcome !!}`) – matticustard May 16 '21 at 02:58
  • Does this answer your question? [Line break in HTML with '\n'](https://stackoverflow.com/questions/39325414/line-break-in-html-with-n) – ParisaN May 16 '21 at 07:03

3 Answers3

0
  1. Replace \n with <br>

  2. Use <p></p>

    My site is designed to help content creators on the web, create a free account and start

    making money now

  3. Use CSS white-space property for \n (example)

ParisaN
  • 1,816
  • 2
  • 23
  • 55
0

try to use <br> on blade, and if you use {!! !!} i think that must be inner html inside your string. cmiiw

faradie
  • 57
  • 8
0

You can save your html text as variable like this

$subtitle_welcome = "<p>My site is designed to help content creators on the web, create a free account and start </p> <p> making money now.</p>";

OR

$subtitle_welcome = "My site is designed to help content creators on the web, create a free account and start <br/> making money now.";

And you have to show in blade

{!! $subtitle_welcome !!}
Ihtisham Khan
  • 417
  • 5
  • 20