Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > <p> or <br>

Reply
Thread Tools

<p> or <br>

 
 
Jim Scott
Guest
Posts: n/a
 
      10-09-2006
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
 
Reply With Quote
 
 
 
 
Steve Pugh
Guest
Posts: n/a
 
      10-09-2006
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

 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      10-09-2006

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.

 
Reply With Quote
 
Jim Scott
Guest
Posts: n/a
 
      10-09-2006
"Andy Dingley" <(E-Mail Removed)> 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
 
Reply With Quote
 
Steve Pugh
Guest
Posts: n/a
 
      10-09-2006
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

 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      10-09-2006

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.

 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      10-09-2006
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).
 
Reply With Quote
 
rvtol_pe@hotmail.com
Guest
Posts: n/a
 
      10-09-2006

> <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.

 
Reply With Quote
 
John Salerno
Guest
Posts: n/a
 
      10-09-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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?
 
Reply With Quote
 
John Salerno
Guest
Posts: n/a
 
      10-09-2006
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments