Search code examples
htmlstringparagraph

Dividing the paragraph HTML


I am currently creating a site. I have one <p> that i have to divide for different strings.

Here is the code:

<p>
  Lorem ipsum - <strong style="color: red;">something.</strong> 
  Lorem ipsum - <strong style="color:blue">something.</strong>\n
  Lorem ipsum - <strong style="color: black;">something.</strong> 
  More lorem ipsum: <strong style="color: indigo;">pls help.</strong>
  Stackoverflow: <strong style="color: purple;">is cool.</strong>
</p>

I want it to make a new line after every <strong> tag, but it outputs a single line. I tried \n, but it doesn't work.

Also please don't ask me to divide it to 3 or 4 paragraphs, I shouldn't do it for this code.


Solution

  • \n isn't for HTML. Try using <br>. How to use:

    <p>Hello! <br /> How are you? <p>

    What it outputs:

    Hello!
    How are you?