Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   <br /> in html 4 (http://www.velocityreviews.com/forums/t162243-br-in-html-4-a.html)

Barbara de Zoete 07-18-2005 09:18 PM

Re: <br /> in html 4
 
On Mon, 18 Jul 2005 22:20:08 +0100, Robert Frost-Bridges
<web@brightonfixedodds.net> wrote:

> Following a suggestion in another thread to investigate the php function
> nl2br() I have been able to format content inputted via a textarea into
> separate paragraphs (well line breaks anyway). These line breaks however
> are the xhtml <br /> (which they are supposed to be) but the page is html
> 4.01. If I validate it however it checks out fine but I'm not sure why? Is
> <br /> ok to use then?


How about checking it yourself
<http://www.w3.org/TR/html401/index/elements.html> ?

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'


Robert Frost-Bridges 07-18-2005 09:20 PM

<br /> in html 4
 
Following a suggestion in another thread to investigate the php function
nl2br() I have been able to format content inputted via a textarea into
separate paragraphs (well line breaks anyway). These line breaks however
are the xhtml <br /> (which they are supposed to be) but the page is html
4.01. If I validate it however it checks out fine but I'm not sure why? Is
<br /> ok to use then?
(It's the page in my sig if you need to see it).

regards,
--
Robert
http://brightonfixedodds.net


Barbara de Zoete 07-18-2005 09:29 PM

Re: <br /> in html 4
 
On Mon, 18 Jul 2005 22:30:48 +0100, Robert Frost-Bridges
<web@brightonfixedodds.net> wrote:

> Barbara de Zoete wrote:
>
>> How about checking it yourself
>> <http://www.w3.org/TR/html401/index/elements.html> ?

>
> I did. It says end tag forbidden but doesn't seem to mention <br />.
>


It gives <br> as the proper syntax for the element. So if <br /> validates in an
otherwise html4 document, something else is going on.

--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'


Robert Frost-Bridges 07-18-2005 09:30 PM

Re: <br /> in html 4
 
Barbara de Zoete wrote:

> How about checking it yourself
> <http://www.w3.org/TR/html401/index/elements.html> ?


I did. It says end tag forbidden but doesn't seem to mention <br />.

--
Robert
http://brightonfixedodds.net


David Dorward 07-18-2005 09:31 PM

Re: <br /> in html 4
 
Robert Frost-Bridges wrote:

> Following a suggestion in another thread to investigate the php function
> nl2br() I have been able to format content inputted via a textarea into
> separate paragraphs (well line breaks anyway). These line breaks however
> are the xhtml <br /> (which they are supposed to be) but the page is html
> 4.01. If I validate it however it checks out fine but I'm not sure why? Is
> <br /> ok to use then?


Short version: No

Longer version: It means the same as <br>&gt; - and some browsers do render
it as such.

Long version: http://www.cs.tut.fi/~jkorpela/html/empty.html

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Robert Frost-Bridges 07-18-2005 09:38 PM

Re: <br /> in html 4
 
Barbara de Zoete wrote:

> It gives <br> as the proper syntax for the element. So if <br /> validates
> in an otherwise html4 document, something else is going on.


That's what I'm wondering.

regards,
--
Robert
http://brightonfixedodds.net


Andrew @ Rockface 07-19-2005 07:35 AM

Re: <br /> in html 4
 
In news:3k2kaoFsd75oU1@individual.net,
Robert Frost-Bridges <web@brightonfixedodds.net> wrote:
> Following a suggestion in another thread to investigate the php
> function nl2br() I have been able to format content inputted via a
> textarea into separate paragraphs (well line breaks anyway). These
> line breaks however are the xhtml <br /> (which they are supposed to
> be) but the page is html
> 4.01. If I validate it however it checks out fine but I'm not sure
> why? Is <br /> ok to use then?
> (It's the page in my sig if you need to see it).
>
> regards,


I wrote this a while back when I was learning php, so it's a little
over-verbose:

function text_to_paragraphs($text) {
// Return formatted string only if not empty
if (!eregi('^\s*$',$text)) {
// Strip final whitespace
$text = trim($text);
// Add <p> to start of string
$text = ereg_replace("^", "<p>", $text);
// Add </p> to end of string
$text = ereg_replace("$", "</p>", $text);
// Stick </p><p> at line ends
$text = ereg_replace("(\r\n|\n|\r)", "</p><p>", $text);
// Chop last <p>
$text = ereg_replace("<p>$", "", $text);
return ($text);
} else {
return false;
}
}

--
Andrew @ Rockface
np: (Winamp is not active ;-)
www.rockface-records.co.uk



Robert Frost-Bridges 07-19-2005 09:18 PM

Re: <br /> in html 4
 
David Dorward wrote:

> Short version: No
>
> Longer version: It means the same as <br>&gt; - and some browsers do
> render it as such.
>
> Long version: http://www.cs.tut.fi/~jkorpela/html/empty.html


Thanks David, I might have known Jukka would have a take on this. Reading it
however, it still seems to imply that <br /> should not validate to html 4
strict. And yet http://brightonfixedodds.net/br_test.html does.

--
Robert
http://brightonfixedodds.net


David Dorward 07-19-2005 09:20 PM

Re: <br /> in html 4
 
Robert Frost-Bridges wrote:

>> Long version: http://www.cs.tut.fi/~jkorpela/html/empty.html

>
> Thanks David, I might have known Jukka would have a take on this. Reading
> it however, it still seems to imply that <br /> should not validate to
> html 4 strict. And yet http://brightonfixedodds.net/br_test.html does.


So does: "<p> <br>> </p>"
But "<meta>> </head>" won't

Character data is allowed in divs.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

Robert Frost-Bridges 07-19-2005 09:20 PM

Re: <br /> in html 4
 
Andrew @ Rockface wrote:

> I wrote this a while back when I was learning php, so it's a little
> over-verbose:

[..code..]

What can I say Andrew, this is just what I'm looking for and works
perfectly. Now to dissect it. (nicely commented too btw, again thank you).

--
Robert
http://brightonfixedodds.net



All times are GMT. The time now is 12:49 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.