Controlling padding on <br> tags?

Discussion in 'CSS' started by dcristo, Sep 14, 2006.

  1. #1
    I am interested to know if it would be possible to control the whitespace generated by the <br> tags? I have a situation where it's creating too much whitespace which I would want to reduce.

    Cheers
     
    dcristo, Sep 14, 2006 IP
  2. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Good question. Not entirely sure on the answer, but I believe as <br> is just a line break, the space is governed by the line-height of the containing element.

    For example, if it's inside a paragraph:
    <p> <br /><br /></p>
    I believe it should be two lines high, which is determined by the line-height of the paragraph.

    So in answer to your question, you could reduce the line height, but it's probably better to control paragraph spacing instead.

    As in do this: <p>hello.</p><p>world</p> rather than <p>hello. <br/><br/>world.</p>, controlling the margin height of the p element, with css. e.g. p {margin-bottom: 0.7em}

    Hope that helps.
     
    AdamSee, Sep 14, 2006 IP
    dcristo likes this.
  3. dcristo

    dcristo Illustrious Member

    Messages:
    19,796
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #3
    Thanks mate I will look into that.
     
    dcristo, Sep 14, 2006 IP
  4. chankit

    chankit Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey, AdamSee, you are right. I tried to control br height before but couldn't figure out the way to do it. Your suggestion did work!

    I add this code to css and the <br /> height can be set, work on both IE and FF.

    br { line-height: 200% }
    Code (markup):
    Thanks again, AdamSee.
     
    chankit, Sep 20, 2006 IP