-3

When ever I want to use new line in HTML code, I do use <br> but when I got code performance testing and been through on some of good practice on HTML. I found that m totally doing wrong when using <br> for new line.

I've been through with this article.

Looking forward to know from community, is this good way or any other thing recommended to use in place of <br> (Like any CSS/javascript Trick)

If there is any other way, can you please refer via code sample.

Thanks a lot in advance.

Viral Shah
  • 2,263
  • 5
  • 21
  • 36

1 Answers1

5

I found that m totally doing wrong when using <br> for new line

Not necessarily. That is, after all, its express (and only) purpose: Starting a new line. For instance, in poetry a line break is frequently meaningful and yet doesn't start a new paragraph, so:

What's in a name? that which we call a rose
<br>By any other name would smell as sweet;

...is a perfectly reasonable way to write those two lines of Romeo and Juliet.

But if you want to start a new paragraph, you wouldn't use <br>, you'd end the current paragraph and start a new one:

<p>This is one paragraph</p>
<p>This is another</p>

Similarly, you wouldn't typically use it to break things up in a container like a div; instead, you'd end one div and start another:

<div>This is one div</div>
<div>This is another</div>

You can also use CSS to style elements that are normally inline or inline-block to be block like div elements are, but that's not usually a good idea (there are always exceptions).

If you want to add space between elements, that's what the padding and margin CSS properties are for.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875