How do you write two lines in html?

I have a HTML document with some distinct rows of text, is there some decided correct way to display them?

Example:

Here are
some lines
of text

Should I use the

tag for each row, or is there some other/better way to do it?

Examples:

Here are

some lines

of text

or

Here are
some lines
of text

Or something completely different?

The CSS & other things isn't really relevant at the moment, I'm just wondering which is the "most correct" way to use.

BoltClock

675k155 gold badges1362 silver badges1334 bronze badges

asked Apr 8, 2018 at 15:52

Sebastian NorrSebastian Norr

6,3222 gold badges11 silver badges16 bronze badges

2

if you have a string with new lines that you want to display for example in a div, you can use white-space: pre-wrap css style:

.multiline {
  white-space: pre-wrap;
}

A multiline text for demo purpose

answered Nov 1, 2019 at 15:27

1

Or you can try this without tag wrapping each line:

Here are some lines of text

answered Mar 2 at 7:33

Lerner ZhangLerner Zhang

5,4522 gold badges42 silver badges57 bronze badges

1

The correct way to do things is using things made for the things you need. If you want a line break (enter), use
; If you want to define a paragraph, use

.

answered Apr 8, 2018 at 16:40

How do you write two lines in html?

D. PardalD. Pardal

5,7641 gold badge16 silver badges35 bronze badges

According to this, the
element is used to insert a line break without starting a new paragraph. Hence you should prefer the second solution over the first.

w3schools comes with a marvelous article about style guides and coding conventions.

answered Apr 8, 2018 at 16:04

How do you write two lines in html?

0

There is no such thing in most correct way, at least according to the current specification of your needs. Yes, you can put them all in separate paragraphs, using the

tag or you can separate them via a
tag at every line. You can also use spans combined with the white-space CSS attribute, so you have a lot of options. To choose the best option for you, you will need to try them out and see what fits your requirements the best.

answered Apr 8, 2018 at 16:06

How do you write two lines in html?

Lajos ArpadLajos Arpad

56.9k32 gold badges94 silver badges162 bronze badges

If you want to create a multiline paragraph that maintains the line seperation in your code without throwing
s everywhere. Simply use the html tag.

answered Dec 23, 2021 at 4:20

How do you write two lines in html?

1

How do I make two lines of text in HTML?

Creating Line Breaks The
tag is used to insert a line break on the web page
. Since the
is an empty element, so there is no need of corresponding
tag.

How do you put multiple line breaks in HTML?

Each
tag inserts an additional line break on the page
. Therefore, you can code multiple
tags back-to-back to produce multiple blank lines down the page.