342

I have a big paragraph of text that is divided into subparagraphs with <br>'s:

<p>
  Blah blah blah.
  <br/>
  Blah blah blah. Blah blah blah. Blah blah blah.
  <br/>
  Blah blah blah.
</p>

I want to widen the gap between these subparagraphs, like there is two <br>'s or something like that. I know that the right way to do this is to use <p></p>, but right now I cannot change this layout, so I am looking for CSS-only solution.

I've tried setting <br>'s line-height and height with display: block, I also Googled and Stack Overflow-ed briefly, but did not find any solution. Is this even possible without changing the layout?

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
n1313
  • 20,555
  • 7
  • 31
  • 46
  • Your formatting may add to the confusion to think br tags had a height value. As pointed out below, they are simply line breaks. Have you tried doing anything similar in your word processor? – Jörg Sep 11 '09 at 08:23
  • Changing height of
    is semantically wrong.
    means you just put another line to your text and single paragraph should have fixed line height. If some text is separated, it should be a separate paragraph.
    – Robo Robok Apr 18 '15 at 20:58
  • [I've written a thorough response to a similar question here.](http://stackoverflow.com/a/25700368/1922144) – davidcondrey May 02 '15 at 07:39
  • If you can, it's probably best to change this to a

    tag which contains three

    tags. That way you can adjust the spacing using css.
    – John Henckel Sep 07 '15 at 15:41
  • 1
    @JohnHenckel A bit misleading since `

    ` tags cannot contain `

    ` tags [see this post](http://stackoverflow.com/questions/8397852/why-p-tag-cant-contain-div-tag-inside-it)
    – deseosuho Mar 14 '16 at 17:47
  • 2
    Sometimes the code we've been given to format is not something we have control over. It is in these times that you start saying to yourself "I can't add

    tags... maybe if I'll just alter the height of the
    's that are being used as spacers instead.

    – Brian Jun 13 '17 at 19:54

34 Answers34

344

Css:

br {
   display: block;
   margin: 10px 0;
}

The solution is probably not cross-browser compatible, but it's something at least. Also consider setting line-height:

line-height:22px;

For Google Chrome, consider setting content:

content: " ";

Other than that, I think you're stuck with a JavaScript solution.

Community
  • 1
  • 1
Duroth
  • 6,315
  • 2
  • 19
  • 23
121

So, peeps above have got basically a similar answer, but here it is very succinctly. Works in Opera, Chrome, Safari & Firefox, most likely IE too?

br {
            display: block; /* makes it have a width */
            content: ""; /* clears default height */
            margin-top: 0; /* change this to whatever height you want it */
}
Isaac Minogue
  • 1,451
  • 1
  • 9
  • 8
84

Here is the correct solution that actually has cross-browser support:

  br {
        line-height: 150%;
     }
Larry K
  • 47,808
  • 15
  • 87
  • 140
htmldrum
  • 2,431
  • 20
  • 20
  • 2
    Not IE7 as far as I can tell. – Serhiy Aug 02 '12 at 19:14
  • 47
    This works for increasing the height of a line break, but not _decreasing_ it. – Pluto Aug 18 '14 at 15:59
  • 3
    @htmldrum When you have no chance to change the HTML but only the CSS, this works great. Thank you! This should be upvoteed and regarded as the correct answer. I think. – flaschbier Sep 01 '15 at 17:20
  • 1
    @Pluto: nigel's answer below works for me to decrease the height! – Anupam Nov 10 '17 at 15:51
  • This works great in Chrome 66.0.3359.181 and Firefox Quantum 60.0.2, but it's not quite right in Edge 42.17134.1.0 and IE 11.48.17134.0. To avoid shifting the line which ends in the BR down from its proper position, in Edge and IE, add a vertical-align:top style, like this: br {line-height:150%;vertical-align:top;} – Dave Burton Jun 10 '18 at 15:27
  • 5
    Unfortunately, no longer working in Chrome v.76. For Edge and IE you need to also add vertical-align:top. I posted a solution here: https://stackoverflow.com/a/29674365/562862 – Dave Burton Sep 14 '19 at 06:35
  • As of November 27, 2021 does **NOT** work in current Firefox. Accepted answer still does work however. – WinEunuuchs2Unix Nov 28 '21 at 00:13
47

Another way is to use an HR. But, and here's the cunning part, make it invisible.

Thus:

<hr style="height:30pt; visibility:hidden;" />

To make a cleaner BR break simulated using the HR: Btw works in all browsers!!

{ height:2px; visibility:hidden; margin-bottom:-1px; }
MrPizzaFace
  • 7,807
  • 15
  • 79
  • 123
Simon Smith
  • 535
  • 4
  • 2
38

I just had this problem, and I got around it by using

<div style="line-height:150%;">
    <br>
</div>
nigel
  • 397
  • 3
  • 2
  • This works great and also gets around the limitation of @htmldrum's answer – Anupam Nov 10 '17 at 15:50
  • I like this too, used it for a thin break e.g. 25%. If the new div block causes wrong/irregular spacing use span instead of div. – Georgie Jan 29 '21 at 05:58
25

As far as I know <br> does not have a height, it merely forces a line break. What you have is a text with some line breaks in addition to the auto-wrap ones, not subparagraphs. You can change the line spacing, but that will affect all lines.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
  • 2
    It seems that there is really no way. I've even tried playing with :before and :after properties, but... :( – n1313 Sep 11 '09 at 08:38
  • 3
    I know this is super old, but @Isaac Minogue has a valid way of doing this. Modifying the `content` property does the trick. – Xandor Oct 16 '19 at 21:31
15

you can apply line-height on that <p> element, so lines become larger.

yoda
  • 10,834
  • 19
  • 64
  • 92
9

I know this is an old question however for me it worked by actually using an empty paragraph with margins:

<p class="" style="margin: 4px;"></p>

Increasing or decreasing the margin size will increase or decrease the distance between elements just like a border would do but adjustable.

On top of that, it is browser compatible.

Sumutiu Marius
  • 421
  • 4
  • 18
8

UPDATED Sep. 13, 2019:

I use <br class=big> to make an oversized line break, when I need one. Until today, I styled it like this:

br.big {line-height:190%;vertical-align:top}

(The vertical-align:top was only needed for IE and Edge.)

That worked in all the major browsers that I tried: Chrome, Firefox, Opera, Brave, PaleMoon, Edge, and IE11.

However, it recently stopped working in Chrome-based browsers: my "big" line breaks turned into normal-sized line breaks.

(I don't know exactly when they broke it. As of Sep 12, 2019 it still works in my out-of-date Chromium Portable 55.0.2883.11, but it's broken in Opera 63.0.3368.71 and Chrome 76.0.3809.132 (both Windows and Android).)

After some trial and error, I ended up with the following substitute, which works in the current versions of all those browsers:

br.big {display:block; content:""; margin-top:0.5em; line-height:190%; vertical-align:top;}

Notes:

line-height:190% works in everything except recent versions of Chrome-based browsers.

vertical-align:top is needed for IE and Edge (in combination with line-height:190%), to get the extra space to come after the preceding line, where it belongs, rather than partially before and partially after.

display:block;content:"";margin-top:0.5em works in Chrome, Opera & Firefox, but not Edge & IE.

An alternative (simpler) way of adding a bit of extra vertical space after a <br> tag, if you don't mind editing the HTML, is with something like this. It works fine in all browsers:

<span style="vertical-align:-37%"> </span><br>

(You can, of course, adjust the "-37%" as needed, for a larger or smaller gap.) Here's a demo page which includes some other variations on the theme:

https://burtonsys.com/a_little_extra_vertical_space_for_br_tag.html



May 28, 2020:

I've updated the demo page; it now demonstrates all of the above techniques:

https://burtonsys.com/a_little_extra_vertical_space_for_br_tag.html

Dave Burton
  • 2,960
  • 29
  • 19
8

Interestingly, if the break tag is written in full-form as follows:

<br></br>

then the CSS line-height:145% works. If the break tag is written as:

<br> or 
<br/> 

then it doesn't work, at least in Chrome, IE and firefox. Weird!

keithphw
  • 380
  • 1
  • 4
  • 14
7

I haven't tried the :before/:after CSS2 pseudo-element before, mainly because it's only supported in IE8 (this concerning IE browsers). This could be the only possible CSS solution:

br:before {
    display: block;
    margin-top: 10px;
    content: "";
}

Here is an example on QuirksMode.

Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114
6
br {   
    content: "";
    margin: 2em;
    display: block;
    margin-bottom: -20px; 
 }

Works in Firefox, Chrome & Safari. Haven't tested in Explorer. (Windows-tablet is out of power.)

Line-breaks, font-size works differently in Firefox & Safari.

DeFliGra
  • 61
  • 1
  • 1
5

Here is a solution that works in IE, Firefox, and Chrome. The idea is to increase the font size of the br element from the body size of 14px to 18px, and lower the element by 4px so the extra size is below the text line. The result is 4px of extra whitespace below the br.

br 
{ 
font-size: 18px; 
vertical-align: -4px; 
}  
David Shaked
  • 81
  • 1
  • 3
  • Just using `vertical-align` seems to do the trick with the `br` tag. I tested this on IE 11. –  Jul 13 '17 at 13:41
4

I had a thought that you might be able to use:

br:after {
    content: ".";
    visibility: hidden;
    display: block;
}

But that didn't work on chrome or firefox.

Just thought I'd mention that in case it occurred to anyone else and I'd save them the trouble.

Sam Lowry
  • 119
  • 1
  • 3
4

What works for me is adding this inline between paragraph tags... not the best solution though.

<br style="line-height:32px">

-------- Edit ---------

I ran into issues with PC/Mac with this... It gives the text the new line-height but does not do the line-break... You may want to do some tests yourself. Sorry!

  • worked for me to manage vertical size at pixel level inside a UIWebView on ios . – Diwann Sep 27 '13 at 14:20
  • I ran into issues with PC/Mac with this... It gives the text the new line-height but does not do the line-break... You may want to do some tests yourself. Sorry! – robinwkurtz Sep 27 '13 at 16:59
4

And remember that (mis)using the <hr> tag as suggested somewhere, will end the <p> tag, so forget about that solution.
If f.ex. something is styled on the surrounding <p>, that style is gone for the rest of the content after the <hr> is inserted.

niels
  • 41
  • 1
  • 3
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Glitch Desire Feb 18 '14 at 12:49
  • Not a critique and not a request. Just trying to say what will happen if you put an hr tag inside a p tag as suggested. And as a newcomer I haven't got enough reputation to comment on the relevant post. So please advice how else I should make such comment (which IMHO is highly relevant with regards to the question). – niels Mar 24 '14 at 14:24
3

i Use these methods, but i dont know if cross-browser

====== Method 1 ======

br {
    display:none;
}

OR ====== Method 2 ======

br {
    display: block;
    margin-bottom: 2px;
    font-size:2px;
    line-height: 2px;
}
br:before {
    display: block;
    margin-top: 2px;
    content: "";
}
br:after {
    content: ".";
    visibility: hidden;
    display: block;
}

OR ====== Method 3 ======

br:after { content: "" }
br { content: "" }
T.Todua
  • 53,146
  • 19
  • 236
  • 237
3

Using some HTML in markdown, having to force <br>s in a list that resulted too cramped, none of the given solutions worked as desired (at least in my setup)

ended up with

<div style="height:10px;font-size:10px;">&nbsp;</div>

I've found it here, extremely close to dorogz suggestion. Of course for standard needs CSS is better

Maicon Mauricio
  • 2,052
  • 1
  • 13
  • 29
lexc
  • 61
  • 3
2

Michael and yoda are both right. What you can do is use the <p> tag, which, being a block tag, uses a bottom-margin to offset the following block, so you can do something similar to this to get bigger spacing:

<p>
    A block of text.
</p>
<p>
    Another block
</p>

Another alternative is to use the block <hr> tag, with which you can explicitly define the height of the spacing.

Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114
  • 1
    Thank you for your answer, but I've stated that I cannot change this layout right now. Of course, I will change it to something saner when it will be possible, but right now -- sorry. – n1313 Sep 11 '09 at 08:29
2

Answering on a more general level for anyone who landed here as they are fixing problems in spacing caused by the <br> tag. I have to do a lot of resets in order to get close to pixel perfect.

br {
    content: " ";
    display: block;
}

For the specific issue I was addressing I had to have a specific space between the lines. I added a margin to the top and bottom.

br {
    content: " ";
    display: block;
    margin: 0.25em 0;
}
JGallardo
  • 11,074
  • 10
  • 82
  • 96
2

I had to develop a solution to convert HTML to PDF, and vertically center the text in table cells, but nothing worked except inputting the plain <br>

So, thinking outside of the box, I have changed the vertical size by adjusting the font-size (in pt).

<font style="font-size: 4pt"><br></font>
3xCh1_23
  • 1,491
  • 1
  • 20
  • 39
2

You don't seem to be able to adjust the height of a BR, but you can make it disappear reliably using display:none

Came across this page while searching for a solution to the following:

I have a situation where 3rd party payment gateway (Worldpay) only lets you customise their payment pages with 10k max of CSS and HTML (no script allowed) that get injected into the body of their template, and after a few BR's, FONT tags etc. Coupled with their DTD which forces IE7/8 into Quirks mode, this makes cross-browser customisation about as hard as it gets!

Turning off BR's makes things a lot more consistent...

1

Sorry if someone else already said this, but the simple solution is to toy around with your "line-height". If you are getting too much space when you use a line break, it's simply because you have your line height set too high. You can correct this in CSS (but know it will affect everything that uses that property) or you can do an inline style to override the CSS.

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/10369583) – JRodDynamite Nov 28 '15 at 17:57
  • I disagree. The OPs question was how to ajust the height of a line break. You can't, so you adjust the line-height to achieve the desired effect. – Daniel Siddall Nov 29 '15 at 23:10
1

Instead of

<br>,<br/>,<hr> or <span></span> and trying different CSS properties to these tag.

I did, I put paragraphs inside a div and gave it line-height:2px

#html

<div class="smallerlineHeight">
   <p>Line1</p>
   <p>Line2</p>
</div>

#css

.smallerlineHeight {
    p {
        line-height: 2px;
    }
}
Sami Haroon
  • 869
  • 10
  • 14
1

Try using the CSS line-height atribute on your p tag that contains the br tag. Remember you can id your p tags if you want to isolate it, though it might be better using a div for isolation, IMO.

Marcus Rickert
  • 4,138
  • 3
  • 24
  • 29
Drizien
  • 11
  • 2
0

you could also use the "block-quote" property in CSS. That would make it so it doesn't effect your individual lines but allows you to set parameters for just the breaks between paragraphs or "block quotes".

UPDATE:
I stand corrected. "blockquote" is actually a html property. You use it just like < p > and < /p > around your work. You could then set the parameters for your block quote in css like

blockquote { margin-top: 20px }

Hope this helps. It is similar to setting the parameters on the br and may or may not be cross browser compatible.

Jonn
  • 123
  • 1
  • 1
  • 9
  • 1
    This is the first time I ever heard of this property. Can you explain this in more detail, please? – n1313 Sep 11 '09 at 08:33
  • I stand corrected. "blockquote" is actually a html property. You use it just like < p > and < /p > around your work. You could then set the parameters for your block quote in css like blockquote { margin-top: 20px } etc etc etc – Jonn Sep 12 '09 at 01:50
0
<span style="line-height:40px;"><br></span> 

You'd have to do this inline and on each
element but it should work on most browsers Fiddle with the line height to get the desired effect. If you make it inline on each element, it should work across most browsers and e-mail(but this is too complex to discuss here).

Liam
  • 11
  • 1
    So why post this if you're not going to give examples? The whole idea of the site is that you *do* discuss it. – Paul Aug 22 '14 at 09:51
0

This did the trick for me when I couldn't get the style spacing to work from the span tag:

        <p style='margin-bottom: 5px' >
            <span>I Agree</span>
        </p>
        <span>I Don't Agree</span>
Gene Bo
  • 11,284
  • 8
  • 90
  • 137
0

Use <div>

<div>Content 1</div>Content 2

This allows for a new line without any vertical space.

This becomes

<div>Content 1</div>Content 2
Artyer
  • 31,034
  • 3
  • 47
  • 75
Joshua Ginn
  • 109
  • 2
  • 11
0

I got it to work in IE7 by using a combo of solutions, but mainly wrapping the Br in DIV as Nigel and others suggested. Added Id and run at="server" so I could remove the BR when removing checkbox from row of checkboxes.

.narrow {
    display: block;
    margin: 0px;
    line-height: 0px;
    content: " "; 
}
<div class="narrow" run at="server"><br></br></div>
TylerH
  • 20,799
  • 66
  • 75
  • 101
0

May be using two br tags is the simplest solution that works with all browsers. But it is repetitive.

<p>
content
</p>
<br /><br />
<p>
content
</p>
<br /><br />
<p>
content
</p>
Miloud Eloumri
  • 779
  • 1
  • 8
  • 14
-1

<br> is for a line break.
<br /> is also for line break, the "/" optionally needed for void elements or for xhtml.
Using <br></br>, browsers will insert two line breaks for both are "virtually" the same.
There is no way to increase the size of a line break because it's just a line break.
Use a div with vilibility set to hidden (<div style="vilibility:hidden; line-height:150%;"</div>) or better still, a paragraph.

dorogz
  • 171
  • 1
  • 9
-1

Might found a solution very easy which you only need to create different type of
. Seem to have worked for me.

example : (html code)

<br/ class="150%space">

(css code)

br[class='150%space']
{
   line-height: 150%;
}
-4

How about just adding a paragraph instead of the line break like so

bla la la bla bla abla la la bla bla abla la la bla bla a

bla la la bla bla abla la la bla bla abla la la bla bla a

bla la la bla bla abla la la bla bla abla la la bla bla a

Then you can specify the lineheight or padding or whatever for that p

  • Yes, I defined the "big" class for both
    and

    . "
    " adds space between lines, and "

    " adds space before a paragraph: ‍‍‍‍‍‍ ‍‍ br.big {display:block; content:""; margin-top:0.5em; line-height:190%; vertical-align:top;} ‍‍‍‍‍‍ ‍‍ p.big {margin-top:1.5em} ‍‍‍‍‍‍ ‍‍ But a problem with the

    tag is that it is styled inconsistently by email programs. When email text containing paragraph breaks is "quoted" in email replies, spacing between paragraphs often changes drastically. So I'm in the habit of using doubled line breaks (ctrl-enter in gmail), in emails.

    – Dave Burton May 28 '20 at 13:14