Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why do some folk use <BR />

1 view
Skip to first unread message

Barrie Heaton

unread,
Apr 6, 2003, 1:45:51 PM4/6/03
to
It there some reason for placing a closing tag in the new line tag <br
/>
I understand why it is done in pearl but not HTML
or am I missing something

this site has it in http://www.practicespot.com/

Barrie,


--
Tower-Forte Website Services
http://www.tower-forte.co.uk/
Tel:01254-774599 Fax:01254-773158 Email: in...@tower-forte.co.uk

Dylan Parry

unread,
Apr 6, 2003, 3:58:02 PM4/6/03
to
Barrie Heaton said:

> It there some reason for placing a closing tag in the new line tag
> <br />
> I understand why it is done in pearl but not HTML
> or am I missing something
>
> this site has it in http://www.practicespot.com/

Do a search for XHTML.

--
Dylan Parry
http://www.webpageworkshop.co.uk
Web Tutorials & Reference Guides

Barrie Heaton

unread,
Apr 6, 2003, 3:08:48 PM4/6/03
to
In message <b6pta9$7e2qe$4...@ID-150186.news.dfncis.de>, Dylan Parry
<dy...@webpageworkshop.co.uk> writes

>Barrie Heaton said:
>
>> It there some reason for placing a closing tag in the new line tag
>> <br />
>> I understand why it is done in pearl but not HTML
>> or am I missing something
>>
>> this site has it in http://www.practicespot.com/
>
>Do a search for XHTML.
>

Thanks

Barrie Heaton

unread,
Apr 6, 2003, 3:07:10 PM4/6/03
to
In message <att09v0rbsjev4jk0...@4ax.com>, "Ian.H [dS]"
<i...@WINDOZEdigiserv.net> writes
>In a fit of excitement on Sun, 6 Apr 2003 18:45:51 +0100, Barrie
>Heaton <to...@tower-forte.co.uk> managed to scribble:

>
>> It there some reason for placing a closing tag in the new line tag
>> <br />
>> I understand why it is done in pearl but not HTML
>> or am I missing something
>
>
>Completely.

>
>
>>
>> this site has it in http://www.practicespot.com/
>>
>> Barrie,
>
>
>How is <br /> ever Perl code!?

Not pearl as such but it is used in there well I have seen it in a few
places
print "<body bgcolor=\"#ffffff\">\n";
print "The following information will be sent:<br>\n";
print "Subject: $form{'subject'}<br>\n";
print "Message:<br> $form{'message'}</br>\n";

I take it that it is used above when the text may be over one line.


>
>the ' />' symbolises the close tag (same as </td> is a closetag of
><td>). Used for XHTML as a shortcut fir <br></br>.

However, my question still stands why would you use </br> it in normal
HTML

Geoff Berrow

unread,
Apr 6, 2003, 3:33:49 PM4/6/03
to
Message-ID: <att09v0rbsjev4jk0...@4ax.com> from Ian.H
[dS] contained the following:

>
>Still interested your reasoning as to how/what/why you brought Perl
>up regarding this.

Confusing it with an escape character?

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

Richard Watson

unread,
Apr 6, 2003, 3:43:21 PM4/6/03
to
Barrie Heaton <to...@tower-forte.co.uk> writes:

>>How is <br /> ever Perl code!?
>

> print "<body bgcolor=\"#ffffff\">\n";
> print "The following information will be sent:<br>\n";
> print "Subject: $form{'subject'}<br>\n";
> print "Message:<br> $form{'message'}</br>\n";

Most of those slashes seem to go the other way though.

> I take it that it is used above when the text may be over one line.

Nope that's a \ as well.

> However, my question still stands why would you use </br> it in normal
> HTML

xhtml (as opposed to html 4) requires that all tags be closed, even
ones that don't obviously appear to need it. Did the doctype of this
document indicate that it was a xhtml document?

--
Richard Watson
http://www.opencolo.com/
High Quality, Value for money colocation

Geoff Berrow

unread,
Apr 6, 2003, 5:51:02 PM4/6/03
to
Message-ID: <FLQFvpHe...@tower-forte.co.uk> from Barrie Heaton
contained the following:

>Not pearl as such but it is used in there well I have seen it in a few
>places
>print "<body bgcolor=\"#ffffff\">\n";
>print "The following information will be sent:<br>\n";
>print "Subject: $form{'subject'}<br>\n";
>print "Message:<br> $form{'message'}</br>\n";
>
>I take it that it is used above when the text may be over one line.

<br> doesn't need a closing tag but as others have pointed out xhtml
(as opposed to html 4) requires that all tags be closed. I think what
the guys are saying is that since <br> should not enclose anything
<br></br> can be written in one tag as <br/>

Don't get confused with the \ character which is an instruction to
take the next character literally in case you wanted to inlude a quote
mark or apostrophe.

The experts will correct me if I'm wrong, but I'm not sure the \n s
in the above example are doing anything.

Grunff

unread,
Apr 6, 2003, 5:52:13 PM4/6/03
to
Geoff Berrow wrote:

> The experts will correct me if I'm wrong, but I'm not sure the \n s
> in the above example are doing anything.

Newline.

--
Grunff

Geoff Berrow

unread,
Apr 6, 2003, 6:05:28 PM4/6/03
to
Message-ID: <b6q7m4$7mbbl$1...@ID-152899.news.dfncis.de> from Grunff
contained the following:

>> The experts will correct me if I'm wrong, but I'm not sure the \n s
>> in the above example are doing anything.
>
>Newline.

I know that. But it does nothing in the above example.

Barrie Heaton

unread,
Apr 6, 2003, 7:04:12 PM4/6/03
to
In message <kd019vk459aea981b...@4ax.com>, "Ian.H [dS]"
<i...@WINDOZEdigiserv.net> writes

>> places
>> print "<body bgcolor=\"#ffffff\">\n";
>> print "The following information will be sent:<br>\n";
>> print "Subject: $form{'subject'}<br>\n";
>> print "Message:<br> $form{'message'}</br>\n";
> ^^^^^
>
> I really hope this isn't live code...

Yip


>
>>
>> I take it that it is used above when the text may be over one line.
>
>

>I'm still not seeing a <br /> here.

Sorry I need to clean my specs

Barrie Heaton

unread,
Apr 6, 2003, 7:30:05 PM4/6/03
to
In message <87u1db5...@chromatica.doilywood.lan>, Richard Watson
<tinne...@doilywood.org.uk> writes

>> However, my question still stands why would you use </br> it in normal
>> HTML
>
>xhtml (as opposed to html 4) requires that all tags be closed, even
>ones that don't obviously appear to need it. Did the doctype of this
>document indicate that it was a xhtml document?


No it has <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

I have been reading up XHML and what I can gather closing tags can
be
<p> bla </p> or if empty <p> </p> It shows <br />, as the
alternative syntax for <br></br> but you can't use the alternative
syntax of <p /> if the paragraph empty. Why bother introducing
alternative syntax <tag /> just leave it as <br></br>

Thanks

Barrie Heaton

unread,
Apr 7, 2003, 4:00:09 AM4/7/03
to
In message <m9f19vcacm49j8u9p...@4ax.com>, "Ian.H [dS]"
<i...@WINDOZEdigiserv.net> writes
>In a fit of excitement on Mon, 7 Apr 2003 00:30:05 +0100, Barrie

>Heaton <to...@tower-forte.co.uk> managed to scribble:
>
>> Why bother introducing
>> alternative syntax <tag /> just leave it as <br></br>
>
>
>It's easier nad quicker is it not to do <br /> rather than <br></br>
>?

Hmmm hours must have been spent debated over that one all to save 4
keystrokes ;-)

>
>Plus, empty <whatever> </whatever> areas are bad practice anyway and
>will more often than not, break a site.. so why would you bother
>using that in the first place? ;)
>


I never have used empty <whatever> </whatever> but the WC3 page on empty
tags <p> <p/> is given as an example they don't say don't and Front
Page seems to love them as well as spacer gifs

rf

unread,
Apr 7, 2003, 4:37:16 AM4/7/03
to

"Barrie Heaton" <to...@tower-forte.co.uk> wrote in message
news:zu1Y2cCJ...@tower-forte.co.uk...

> In message <m9f19vcacm49j8u9p...@4ax.com>, "Ian.H [dS]"
> <i...@WINDOZEdigiserv.net> writes
> >In a fit of excitement on Mon, 7 Apr 2003 00:30:05 +0100, Barrie
> >Heaton <to...@tower-forte.co.uk> managed to scribble:
> >
> >> Why bother introducing
> >> alternative syntax <tag /> just leave it as <br></br>
> >
> >
> >It's easier nad quicker is it not to do <br /> rather than <br></br>
> >?
>
> Hmmm hours must have been spent debated over that one all to save 4
> keystrokes ;-)

Hmmm... I have been watching this thread for a while. Nobody yet has got it
fully correct.

The concept is the "element". An [X]HTML element consists of: an opening
tag; some content; a closing tag.

For paragraphs it's easy, <p>content</p>. However some elements like break
and horizontal rule do not have any content. They are not just 'empty' in
the sense that <p></p> is 'empty. They really do not have any content part.
For such elements the closing tag is not required, and in fact is not
allowed. There is no </br> tag. You can put one in if you like but it will
just be error-corrected away.

So, for HTML we have <br>.

XHTML insists that every element be closed. Note: element, not tag (a tag is
'closed' with a >). So how do we close an element if it has no closing tag?
Close it in the opening tag - <br/>.

Since early browsers do not understand XHTML this will fire error recovery
as <br/> is not a known tag. To trick them we write it as <br />. The older
browsers see a break element with an attribute of /. This is an unknown
attribute and is ignored. An XHTML browser will be quite happy with <br />.

The reason <br /> appears in HTML documents is that the author has seen it
somewhere else and has just copied it without fully knowing what it actually
means.

Cheers
Richard.


Barrie Heaton

unread,
Apr 7, 2003, 4:48:32 AM4/7/03
to
In message <0Naka.939$1h6....@news-server.bigpond.net.au>, rf
<making...@the.time> writes

>Since early browsers do not understand XHTML this will fire error
>recovery as <br/> is not a known tag. To trick them we write it as <br
>/>. The older browsers see a break element with an attribute of /. This
>is an unknown attribute and is ignored. An XHTML browser will be quite
>happy with <br />.
>
>The reason <br /> appears in HTML documents is that the author has seen
>it somewhere else and has just copied it without fully knowing what it
>actually means.
>
>Cheers
>Richard.

Thanks

now why can't WC3 put in English

rf

unread,
Apr 7, 2003, 5:15:21 AM4/7/03
to

"Barrie Heaton" <to...@tower-forte.co.uk> wrote in message
news:++vbSeAg...@tower-forte.co.uk...

> In message <0Naka.939$1h6....@news-server.bigpond.net.au>, rf
> <making...@the.time> writes
> > [discussion of <br />]

> now why can't WC3 put in English

W3C actually. Then pull that name apart. W3 of course means www but W3C
sounds better than wwwC.

C means <shudder>Consortium</shudder>.

The chances of a document being obfuscated beyond readability rise in
geometric proportion to the number of people involved in producing said
document.

Here is a list of the members of the W3C:

http://www.w3.org/Consortium/Member/List

QED.

Cheers
Richard.


Jack Howard

unread,
Apr 7, 2003, 6:45:14 AM4/7/03
to
In message <lh719v04peuvsvdbd...@4ax.com>, Geoff Berrow
<$b...@ckdog.co.uk> writes

>Message-ID: <FLQFvpHe...@tower-forte.co.uk> from Barrie Heaton
>contained the following:
>
>>Not pearl as such but it is used in there well I have seen it in a few
>>places
>>print "<body bgcolor=\"#ffffff\">\n";
>>print "The following information will be sent:<br>\n";
>>print "Subject: $form{'subject'}<br>\n";
>>print "Message:<br> $form{'message'}</br>\n";
>>
>>I take it that it is used above when the text may be over one line.
>
><br> doesn't need a closing tag but as others have pointed out xhtml
>(as opposed to html 4) requires that all tags be closed. I think what
>the guys are saying is that since <br> should not enclose anything
><br></br> can be written in one tag as <br/>
>
>Don't get confused with the \ character which is an instruction to
>take the next character literally in case you wanted to inlude a quote
>mark or apostrophe.
>
>The experts will correct me if I'm wrong, but I'm not sure the \n s
>in the above example are doing anything.

\n is general Perl (and most Unix, IIRC) syntax for newline.

When I'm using Perl (note *not* "Pearl"!) to generate HTML, I'll usually
code the lines thus:

if ($debug) { print "<p>The value of \$data is '$data'<br>\n"; }

In this case the \ before the first $data tells Perl to actually print
the character $, rather than expanding it into a variable. The <br> on
the end ensures that this debug line stands on it's own, for easy
reading, and the \n likewise adds a line-break to the source code of the
page, to keep that readable too.

The result of the above line in a browser would be:

<other data>
The value of $data is 'sheep'
<rest of page>

And the source code would look like this:

[stuff...]
<p>The value of $data is 'sheep'<br>
[more stuff...]

Now, were I to be generating xhtml instead of html, I'd replace the <br>
with <br />, but I've never yet seen any reason to even attempt to
produce xvtml (valid or otherwise) from a cgi script. :-)

--
- Jack Howard, Systems Development Engineer, Firstnet Services Limited
===[ http://www.firstnet.net.uk <--- Total Internet Solutions ]===

===[ This message subject to http://www.firstnet.net.uk/disclaimer.html ]===

hognoxious

unread,
Apr 7, 2003, 10:29:19 AM4/7/03
to
"Barrie Heaton" <to...@tower-forte.co.uk> wrote in message
news:zu1Y2cCJ...@tower-forte.co.uk...

> In message <m9f19vcacm49j8u9p...@4ax.com>, "Ian.H [dS]"
> <i...@WINDOZEdigiserv.net> writes
...

> >
> >It's easier nad quicker is it not to do <br /> rather than <br></br>
> >?
>
> Hmmm hours must have been spent debated over that one all to save 4
> keystrokes ;-)

That's rich, coming from someone who has a compulsion to add a letter to
'perl'.


Andy Mabbett

unread,
Apr 7, 2003, 1:36:25 PM4/7/03
to
In message <0Naka.939$1h6....@news-server.bigpond.net.au>, rf
<making...@the.time> writes
>The concept is the "element". An [X]HTML element consists of: an
>opening tag; some content; a closing tag.
>
>For paragraphs it's easy, <p>content</p>. However some elements like
>break and horizontal rule do not have any content. They are not just
>'empty' in the sense that <p></p> is 'empty. They really do not have
>any content part.

Alternatively, they have the implied content:

<br>[line break]</br>
<hr>[horizontal rule]</hr>

--
Andy Mabbett Not in my name: <http://www.stopwar.org.uk/>

Geneva Convention:
<http://www.guardian.co.uk/usa/story/0,12271,921410,00.html>

rf

unread,
Apr 7, 2003, 7:43:35 PM4/7/03
to

"Andy Mabbett" <usenet...@pigsonthewing.org.uk> wrote in message
news:YM6rYLnZ...@pigsonthewing.org.uk...

> In message <0Naka.939$1h6....@news-server.bigpond.net.au>, rf
> <making...@the.time> writes
> >The concept is the "element". An [X]HTML element consists of: an
> >opening tag; some content; a closing tag.
> >
> >For paragraphs it's easy, <p>content</p>. However some elements like
> >break and horizontal rule do not have any content. They are not just
> >'empty' in the sense that <p></p> is 'empty. They really do not have
> >any content part.
>
> Alternatively, they have the implied content:
>
> <br>[line break]</br>
> <hr>[horizontal rule]</hr>

There is no </br> or </hr> tag.

Go here
http://www.w3.org/TR/html4/present/graphics.html#h-15.3
for the BR element and here
http://www.w3.org/TR/html4/struct/text.html#h-9.3.2.1
for the HR element.

<quote>
Start tag: required, End tag: forbidden
</quote>

Cheers
Richard.


Owen Rees

unread,
Apr 9, 2003, 5:24:39 PM4/9/03
to
On Mon, 07 Apr 2003 10:20:44 GMT, "Ian.H [dS]" <i...@WINDOZEdigiserv.net>
wrote in <i6k29vodp100tf2ik...@4ax.com>:

>In a fit of excitement on Mon, 07 Apr 2003 08:37:16 GMT, "rf"
><making...@the.time> managed to scribble:


>
>> The reason <br /> appears in HTML documents is that the author has
>> seen it somewhere else and has just copied it without fully knowing
>> what it actually means.

>...and AFAIK, actually fails validation under HTML4.x DTD.

It passes, but it does not mean what you might think (unless you are an
SGML expert).

I put together a little test file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content=
"text/html; charset=ISO-8859-1">
<title>Test</title>
</head>
<body>
<p>a line<br />with a break</p>
</body>
</html>

and uploaded it to the W3C validator - it passed. Trying again with the
extended interface <http://validator.w3.org/file-upload.html> with "Show
Parse Tree" enabled reveals that the '>' in "<br />" is not treated as
part of the tag, it is data. The WDG validator (with warnings enabled)
says: "Warning: net-enabling start-tag; possibly missing required quotes
around an attribute value" pointing at the '/' in "<br />".
It seems that you can get away with using it, but only because browsers
do not work by parsing the input strictly according to SGML and the DTD.

A little bit of googling turned up some discussion of this issue - it is
worse if you do it to a <meta ... /> in the <head> - the '>', being
data, ends the <head> and starts the <body> as far as the validator is
concerned, so it then complains about <title> etc (at least according to
the discussion I found - I have not tried it).

--
Owen Rees - opinions expressed here are mine; for a full disclaimer
visit <http://homepages.tesco.net/~owen.rees/index.html#disclaimer>
for e-mail use "owen.rees at tesco.net" instead of the From address

Nick Kew

unread,
Apr 9, 2003, 5:59:36 PM4/9/03
to
In article <ao299von25om8ikgo...@4ax.com>, one of infinite monkeys

at the keyboard of Owen Rees <or...@hotmail.com> wrote:

>>In a fit of excitement on Mon, 07 Apr 2003 08:37:16 GMT, "rf"
>><making...@the.time> managed to scribble:
>>
>>> The reason <br /> appears in HTML documents is that the author has
>>> seen it somewhere else and has just copied it without fully knowing
>>> what it actually means.

Sounds likely.

>>...and AFAIK, actually fails validation under HTML4.x DTD.

Often, yes.

> It passes, but it does not mean what you might think (unless you are an
> SGML expert).

Indeed, it may pass.

> I put together a little test file:

(chop)

<blockquote cite="http://valet.webthing.com/page/parsemode.html">

For example, the following is a valid HTML document:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">

<title/HTML example/
<p<p/This is the second paragraph in this document.
The first was empty.

</blockquote>

This example - from Page Valet's Help page describing Parse modes -
stretches HTML expectations rather further than yours, beyond the
bounds of what tag-soup browsers can typically be expected to fix.

> and uploaded it to the W3C validator - it passed. Trying again with the
> extended interface <http://validator.w3.org/file-upload.html> with "Show
> Parse Tree" enabled reveals that the '>' in "<br />" is not treated as
> part of the tag, it is data.

You'll see that more graphically with the "visual" presentation options
at Page Valet.

> The WDG validator (with warnings enabled)
> says: "Warning: net-enabling start-tag; possibly missing required quotes
> around an attribute value" pointing at the '/' in "<br />".

Yep. Enabling warnings at the WDG Validator is essentially equivalent
to selecting the (default) "web" parse mode at Page Valet. But the latter
will suggest you may be confusing HTML and XHTML syntax in its warning
message.

> It seems that you can get away with using it, but only because browsers
> do not work by parsing the input strictly according to SGML and the DTD.

I believe that observation is the foundation of the notorious Appendix C.

> A little bit of googling turned up some discussion of this issue - it is
> worse if you do it to a <meta ... /> in the <head> - the '>', being
> data, ends the <head> and starts the <body> as far as the validator is
> concerned, so it then complains about <title> etc (at least according to
> the discussion I found - I have not tried it).

Only if you use the Legacy (aka Transitional) DTD. In the strict DTD,
loose character data isn't allowed in <body>, so the HEAD isn't implicitly
closed, and you get *much* less misleading (and fewer) error messages!

--
Nick Kew

Available for contract work - Programming, Unix, Networking, Markup, etc.

0 new messages