user9855996
user9855996

Reputation:

How to use <br> multiple times in HTML

This is my code:

<HTML>
Hello
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Good bye!
</HTML>

Is there an easier way instead of using 10
tags?

Upvotes: 4

Views: 12204

Answers (5)

rahul-ahuja
rahul-ahuja

Reputation: 1424

A workaround way of adding adjustable vertical space:
(works in Jupyter Notebook markdown cells)

<hr style="border:none; margin-bottom:2.2em">

Change the em number to adjust.

Upvotes: 0

Stack Underflow
Stack Underflow

Reputation: 38

You can make this happen using javascript. Sort of like this:

var breakItem = document.getElementById("break")

breakItem.innerHTML = "<br>".repeat(10)
<HTML>
Hello
<div id="break"></div>
Good bye!
</HTML>

The .repeat function repeats the string <br> 10 times, then adds it to the div's innerHTML.

Upvotes: 1

Aditya
Aditya

Reputation: 1104

<br> is use for line break in html.

If you want to add multiple blank line you can use

<br style="line-height:N;">

where N is the number of blank line or you can write in px

e.g.

<br style = "line-height:100;">

or

<br style = "line-height:100px;">

first one give you 100 blank line and second one give you 100px space

Upvotes: 5

Moffen
Moffen

Reputation: 2003

It depends on what you are after, if you are after just the space from multiple <br> then you can use css positioning elements insteads (padding, top, margin, etc.) Or, if you specifically want x amount of <br> elements, you can use an inline JavaScript for loop:

<HTML>
    Hello
    <script>
        var i;
        for (i = 0; i < 10; i++) { 
            document.write("<br>");
        }
    </script>
    Good bye!

</HTML>

Upvotes: 0

rafaelcastrocouto
rafaelcastrocouto

Reputation: 12161

You can use CSS margin-bottom property

https://developer.mozilla.org/en-US/docs/Web/CSS/margin

.br {margin-bottom: 10em}
<HTML>
Hello
<p class="br"></p>
Good bye!
</HTML>

Upvotes: 4

Related Questions