XHTML in HTML 4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KeredDrahcir
    Contributor
    • Nov 2009
    • 426

    #1

    XHTML in HTML 4

    I've got an HTML 4 page and I'm using textareas to gather the content to display on the page. I'm giving people the option to preserve the line breaks and using nl2br on the output to keep line breaks in.
    The problem is that the line breaks are coming out as <br/> and that is XHTML. The W3C Validator says to use <br> and so 82 out of 84 warnings are due to this. Is there some way to get it to generate the empty br tags rather than self-closed ones?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    use the second parameter that indicates XHTML: nl2br($str, false);

    Comment

    • KeredDrahcir
      Contributor
      • Nov 2009
      • 426

      #3
      Does that mean I put the second parameter as true it will include <br> tags as opposed to <br/> tags or is it the other way round?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        see nl2br() for the correct usage.

        Comment

        • KeredDrahcir
          Contributor
          • Nov 2009
          • 426

          #5
          Thanks. That's great.

          Comment

          Working...