<br /> in html 4

B

Barbara de Zoete

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 |
`-------------------------------------------------- --<--@ ------------'
 
R

Robert Frost-Bridges

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,
 
B

Barbara de Zoete

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 |
`-------------------------------------------------- --<--@ ------------'
 
D

David Dorward

Robert said:
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
 
R

Robert Frost-Bridges

Barbara said:
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,
 
A

Andrew @ Rockface

In
Robert Frost-Bridges said:
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;
}
}
 
R

Robert Frost-Bridges

Andrew said:
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).
 
R

Robert Frost-Bridges

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

Character data is allowed in divs.

Ah yes, I've got it now. Thank you for your time.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top