0

Having - HTML and its CSS -

HTML -

<html>
<head>
    <link href="css/breakLineInBrowser.css" rel="stylesheet">
</head>
<body>
    <p>
     Line 1. 
     Line 2.
     Line 3.
    </p>
</body>
</html> 

CSS -

p {

}

DEMO

In the browser it appears as -

Line 1. Line 2. Line 3.

Which CSS property have I add into the p {} in order to get it display as -

Line 1. 
Line 2.
Line 3. 

?

(I don't look for solution with </br> in the HTML)

URL87
  • 10,667
  • 35
  • 107
  • 174

4 Answers4

2

You can use white-space property of css.

white-space: pre-line;
Rashmin Javiya
  • 5,173
  • 3
  • 27
  • 49
1

I think you have three options.

  1. Using <pre> HTML tag.

    <p>
     <pre> 
      Line 1. 
      Line 2. 
      Line 3. 
     </pre> 
    </p>
    
  2. Using <br\> HTML tag

    <p> 
     Line 1.<br/> 
     Line 2.<br/> 
     Line 3.<br/> 
    </p>
    
  3. Or using css styles

    <p style="white-space: pre-line;">
    line1
    line2
    line3
    </p>
    

Anyway please read other answers too.

Govinnage Rasika Perera
  • 2,134
  • 1
  • 21
  • 33
0

Why don't you use the paragraph?

<p>Line 1.</p>
<p>Line 2.</p>
<p>Line 3.</p>
Kets
  • 438
  • 2
  • 8
  • 24
0

What you search is the pre-Element. It's css counterpart is

pre{ white-space: pre ; display: block; unicode-bidi: embed }

(As seen here)

Sebb
  • 871
  • 6
  • 16