<p> or <br>

Discussion in 'HTML' started by Jim Scott, Oct 9, 2006.

  1. Jim Scott

    Jim Scott Guest

    Is it a debateable point or 'whatever suits' as to whether test is
    presented using <p> or <br> tags?

    --
    Jim
    Tyneside UK
    http://www.jimscott.co.uk
    Jim Scott, Oct 9, 2006
    #1
    1. Advertising

  2. Jim Scott

    Steve Pugh Guest

    Jim Scott wrote:
    > Is it a debateable point or 'whatever suits' as to whether test is
    > presented using <p> or <br> tags?


    No.

    If it's a paragraph then mark it up with a <p> element.

    If it's a line break then mark it up with a <br> element.

    They mean different things and in most browsers result in a different
    presentation.

    Steve
    Steve Pugh, Oct 9, 2006
    #2
    1. Advertising

  3. Jim Scott

    Andy Dingley Guest

    Jim Scott wrote:

    > Is it a debateable point or 'whatever suits' as to whether test is
    > presented using <p> or <br> tags?


    Neither - it's very clear.

    <p>Marks the boundaries of a paragraph. <br> is an inline element that
    marks a line break, where it occurs _within_ some piece of text. That's
    really all there is to it - it's pretty clearly stated, if only you
    follow the HTML spec through in detail.

    <br><br> is always wrong. You've broken the line once, how do you break
    it a second time?

    If you want a debate, then it's less clear-cut when you should use <p>
    and <div>. Obviously <p> is used for paragraphs and <div> should be
    used for "chunks fo text that aren't a grammatical paragraph", but this
    is a viable grammar question about similar HTML constructs when <p> vs.
    <br> is really comparing chalk and cheese.
    Andy Dingley, Oct 9, 2006
    #3
  4. Jim Scott

    Jim Scott Guest

    "Andy Dingley" <> wrote in news:1160399014.713784.222520
    @c28g2000cwb.googlegroups.com:

    > Jim Scott wrote:
    >
    >> Is it a debateable point or 'whatever suits' as to whether test is
    >> presented using <p> or <br> tags?

    >
    > Neither - it's very clear.
    >
    > <p>Marks the boundaries of a paragraph. <br> is an inline element that
    > marks a line break, where it occurs _within_ some piece of text. That's
    > really all there is to it - it's pretty clearly stated, if only you
    > follow the HTML spec through in detail.
    >
    > <br><br> is always wrong. You've broken the line once, how do you break
    > it a second time?
    >
    > If you want a debate, then it's less clear-cut when you should use <p>
    > and <div>. Obviously <p> is used for paragraphs and <div> should be
    > used for "chunks fo text that aren't a grammatical paragraph", but this
    > is a viable grammar question about similar HTML constructs when <p> vs.
    > <br> is really comparing chalk and cheese.
    >

    Not quite.
    On my site, which is almost all pictures with text, using <br> avoids a space
    appearing between the text and the picture or is that because I use </p>?
    --
    Jim
    Tyneside UK
    http://www.jimscott.co.uk
    Jim Scott, Oct 9, 2006
    #4
  5. Jim Scott

    Steve Pugh Guest

    Jim Scott wrote:

    > On my site, which is almost all pictures with text, using <br> avoids a space
    > appearing between the text and the picture or is that because I use </p>?


    Most browsers give top and bottom margins to paragraphs. So <p>...</p>
    will have some white space before and after it.

    You can suggest that the margins be zero size via CSS, so if it is
    logically a paragraph but you don't want the white space, use
    <p>...</p> and set the margins to zero in CSS. But if it is not
    logically a paragraph don't use <p>...</p>.

    Steve
    Steve Pugh, Oct 9, 2006
    #5
  6. Jim Scott

    Andy Dingley Guest

    Jim Scott wrote:

    > On my site, which is almost all pictures with text, using <br> avoids a space
    > appearing between the text and the picture or is that because I use </p>?


    What's a "space" ? Sounds like a presentation issue, in which case
    don't worry about it in the HTML, leave it to the CSS.

    If you <img> is part of the same para as the text, then use <br>
    between them.

    If your test is a separate paragraph beneath the image (or above, or
    alongside it) then use <p>...</p> and put the <img> elsewhere.
    Andy Dingley, Oct 9, 2006
    #6
  7. Jim Scott

    jojo Guest

    Andy Dingley wrote:
    >
    >> On my site, which is almost all pictures with text, using <br> avoids a space
    >> appearing between the text and the picture or is that because I use </p>?

    >
    > What's a "space" ? Sounds like a presentation issue, in which case
    > don't worry about it in the HTML, leave it to the CSS.
    >
    > If you <img> is part of the same para as the text, then use <br>
    > between them.
    >
    > If your test is a separate paragraph beneath the image (or above, or
    > alongside it) then use <p>...</p> and put the <img> elsewhere.
    >

    And if you have got a image with some subtitle or description use a
    <div> (because it'S no "grammatical paragraph" as andy already said).
    jojo, Oct 9, 2006
    #7
  8. Jim Scott

    Guest


    > <br><br> is always wrong. You've broken the line once, how do you break
    > it a second time?


    I don't see why this is wrong. BR is a single line break and there is
    nobody forbidding you to use 2 of them and it will validate correctly.
    The P tag simply helps you to define a paragraph and to have some more
    flexibility when it comes to styling; however, there are plenty of
    cases that would have a double BR making your code more readable.
    , Oct 9, 2006
    #8
  9. Jim Scott

    John Salerno Guest

    wrote:
    >> <br><br> is always wrong. You've broken the line once, how do you break
    >> it a second time?

    >
    > I don't see why this is wrong.


    Probably because most people do <br><br> when they want to create space
    on the page, and that's a stylistic thing.

    > there are plenty of
    > cases that would have a double BR making your code more readable.


    Do you mean more readable in a text editor? If so, why would you use an
    HTML tag for this?
    John Salerno, Oct 9, 2006
    #9
  10. Jim Scott

    John Salerno Guest

    Andy Dingley wrote:

    > Obviously <p> is used for paragraphs and <div> should be
    > used for "chunks fo text that aren't a grammatical paragraph"


    Just out of curiosity, where did you get that quote from? I can see why
    it would be confusing if <div> is still defined in terms of "text" and
    "paragraph", but it seems (to me, at least) that <div> is really used
    for sections of your webpage that are distinct in terms of overall
    content, i.e. a header and a footer can each be a <div>, the main body
    could be, sidebars could be, etc. In those terms, it has nothing to do
    with text or paragraphs necessarily.
    John Salerno, Oct 9, 2006
    #10
  11. wrote:
    >> <br><br> is always wrong. You've broken the line once, how do you break
    >> it a second time?

    >
    > I don't see why this is wrong. BR is a single line break and there is
    > nobody forbidding you to use 2 of them and it will validate correctly.


    "Colorless green dreams sleep furiously" is a syntactically correct
    English sentence that would would pass an English validator if one
    existed, but it is also meaningless.

    This is an example of
    a sentence with a line break in it.

    This is another example of



    a sentence with a line break in it.

    In each case, the sentence is broken in one place, i.e., there is *one*
    line break. In the second example, I choose to make the two parts appear
    farther apart than they normally would, and in an e-mail I have to use
    multiple line break characters to make that happen, but still, the text
    is broken only *once*. In HTML, <br> represents the fact of the line
    being broken, and <br><br> is redundant; layout is controlled using
    styles. If you want something that looks like this:

    The equation

    z^2 = x^2 + y^2

    is the heart of the Pythagorean Theorem.

    use styles.

    ..subquote { display: block; margin: 1em 0 1em 2em; }

    <p>The equation <span class="subquote">z^2 = x^2 + y^2</span> is the
    heart of the Pythagorean Theorem.</p>

    > The P tag simply helps you to define a paragraph


    It doesn't help you to define one. It denotes one.

    > and to have some more
    > flexibility when it comes to styling; however, there are plenty of
    > cases that would have a double BR making your code more readable.


    There are cases where extra spacing makes your code more readable. A
    double BR isn't the correct way to accomplish that. Let's put it this
    way: why is the amount of spacing created by two BRs necessarily what
    you want? What if the desirable amount of space corresponds to 1.3 BRs?
    What if the part after the break (as in the above example) shouldn't be
    aligned with the part before it? Then what?
    Harlan Messinger, Oct 9, 2006
    #11
  12. Jim Scott

    patrick j Guest

    On Mon, 9 Oct 2006 17:26:29 +0100, wrote
    (in article <>):

    >
    >> <br><br> is always wrong. You've broken the line once, how do you break
    >> it a second time?

    >
    > I don't see why this is wrong. BR is a single line break and there is
    > nobody forbidding you to use 2 of them and it will validate correctly.
    > The P tag simply helps you to define a paragraph and to have some more
    > flexibility when it comes to styling; however, there are plenty of
    > cases that would have a double BR making your code more readable.
    >


    I think it's a matter of style.

    I would always tend to use <p> and then use CSS to adjust spacing.

    This is also true of my use of word processors. I always use the para
    spacing to create space between para's, I never use empty line breaks
    as do many people.

    The advantage I think of adjusting spacing for <p> is that it is
    incremental whereas using more than one <br> is not very adjustable.

    At least that's the way I see it :)

    --
    Patrick
    Brighton, UK
    patrick j, Oct 9, 2006
    #12
  13. Jim Scott

    Andy Dingley Guest

    John Salerno wrote:

    > Andy Dingley wrote:
    >
    > > Obviously <p> is used for paragraphs and <div> should be
    > > used for "chunks fo text that aren't a grammatical paragraph"

    >
    > Just out of curiosity, where did you get that quote from?


    Not a quote, it's just indicating an approximation -- in particular
    that usinmg <div> in this way (non-para text) doesn't also rule it out
    for the other uses of <div>. Quite obviously the content model of
    <div> is different from <p> for a start - you can put <div> or <p>
    inside a <div>, but never inside a <p>
    Andy Dingley, Oct 9, 2006
    #13
  14. Jim Scott

    RvT Guest

    John Salerno schreef:

    > Do you mean more readable in a text editor? If so, why would you use an
    > HTML tag for this?


    No, more readable when editing your HTML code in an editor. <p></p> is
    a new nesting, making the code in certain situations more difficult to
    read.
    RvT, Oct 9, 2006
    #14
  15. On 2006-10-09, wrote:
    >
    >> <br><br> is always wrong. You've broken the line once, how do you break
    >> it a second time?

    >
    > I don't see why this is wrong. BR is a single line break and there is
    > nobody forbidding you to use 2 of them and it will validate correctly.
    > The P tag simply helps you to define a paragraph and to have some more
    > flexibility when it comes to styling; however, there are plenty of
    > cases that would have a double BR making your code more readable.


    All cases where you want a two-line space can be handled with CSS.

    --
    Chris F.A. Johnson <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
    Chris F.A. Johnson, Oct 9, 2006
    #15
  16. Jim Scott

    Jim S Guest

    On Mon, 9 Oct 2006 17:21:12 -0400, Chris F.A. Johnson wrote:

    > On 2006-10-09, wrote:
    >>
    >>> <br><br> is always wrong. You've broken the line once, how do you break
    >>> it a second time?

    >>
    >> I don't see why this is wrong. BR is a single line break and there is
    >> nobody forbidding you to use 2 of them and it will validate correctly.
    >> The P tag simply helps you to define a paragraph and to have some more
    >> flexibility when it comes to styling; however, there are plenty of
    >> cases that would have a double BR making your code more readable.

    >
    > All cases where you want a two-line space can be handled with CSS.


    Hello!
    If you come in the middle of a thread, please read what went before.
    I am trying to avoid a 'whitespace' as I now know it is called (jargon
    bluddy jardon) not create one extra.
    --
    Jim S
    Tyneside UK
    http://www.jimscott.co.uk
    Jim S, Oct 10, 2006
    #16
  17. Jim S wrote:
    > On Mon, 9 Oct 2006 17:21:12 -0400, Chris F.A. Johnson wrote:
    >> On 2006-10-09, wrote:
    >>> The P tag simply helps you to define a paragraph and to have some
    >>> more flexibility when it comes to styling; however, there are
    >>> plenty of cases that would have a double BR making your code more
    >>> readable.

    >> All cases where you want a two-line space can be handled with CSS.

    >
    > If you come in the middle of a thread, please read what went before.
    > I am trying to avoid a 'whitespace' as I now know it is called
    > (jargon bluddy jardon) not create one extra.


    Chris was replying to rtvol_pe, not to you.
    Leif K-Brooks, Oct 10, 2006
    #17
  18. Jim Scott

    Toby Inkster Guest

    Jim Scott wrote:

    > On my site, which is almost all pictures with text, using <br> avoids a space
    > appearing between the text and the picture or is that because I use </p>?


    Note the difference in rendering between:

    <p>text <img></p>

    and

    <p>text</p> <img>

    Also, note that "</p>" is an optional tag. So which of the two examples
    above do you think is equivalent to:

    <p>text <img>

    ?

    It's the first one.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Oct 10, 2006
    #18
  19. Jim Scott

    jojo Guest

    Toby Inkster wrote:

    > Also, note that "</p>" is an optional tag.


    It is optional in HTML but required in XHTML.
    jojo, Oct 10, 2006
    #19
  20. Jim Scott

    jojo Guest

    Jim S wrote:

    > If you come in the middle of a thread,


    Only the OP comes at the beginning...

    > please read what went before.


    I'm sure he has.
    jojo, Oct 10, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page