Re: The nl2br() function and browser handling of multiple BR tags
| From: | Hannes Magnusson | Date: | Sun, 23 Sep 2012 19:32:35 +0000 |
| Subject: | Re: The nl2br() function and browser handling of multiple BR tags | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969384099@lists.php.net to get a copy of this message | ||
On Sun, Sep 23, 2012 at 7:55 PM, <mezzanine@safe-mail.net> wrote:
> The current functionality of the nl2br() function is to insert a
> <br /> tag before each newline in a string. (If the $is_xhtml
> parameter is set to false, <br> tags will be inserted instead of
> <br /> tags.) According to the documentation for version 2.8.7 of
> the Lynx browser, the correct method for inserting blank lines into
> an HTML document is to enclose a sequence of newlines between PRE
> tags. In addition, the Lynx browser may collapse a sequence of
> multiple BR tags into a single line break, depending on how the
> browser is configured. More details about this aspect of the Lynx
> browser are available at
> <http://lynx.isc.org/release/lynx2-8-7/
> lynx_help/body.html#COLLAPSE_BR_TAGS> on the Web. The HTML 4.01
> specification talks about the BR tag in section 9.3.2.1; details are
> available at <
>http://www.w3.org/TR/1999/REC-html401-19991224/struct/
> text.html#h-9.3.2.1> on the Web. The specification states that "[t]he
> BR element forcibly breaks (ends) the current line of text," though
> it is not clear as to the situation where a "line of text" consists
> entirely of white space, or when two or more BR elements are separated
> by newlines.
>
> The question is, should the nl2br() function be changed to enclose
> sequences of multiple newlines in PRE tags, as opposed to inserting a
> BR element before each newline? (For that matter, what exactly is the
> correct method for rendering multiple newlines for an HTML document?)
> As a possible alternative, would it be useful add a note about the
> issue of multiple newlines and HTML rendering by browsers to the
> documentation for the nl2br() function?
>
I can't tell if this is first class quality trolling or not :)
But no, the nl2br() will not change this (imagine the backwards
compatibility break).
The reason why lynx has this option is probably to preserve screen
real-estate as many website are silly and use <br> tags to wrap
content around images.. which you don't see in lynx anyway.
-Hannes