in reply to br tag in CGI.pm V2.91

In XML (including XHTML), the following are all equivalent:

<foo></foo>
<foo />
<foo/>

I think this is true for all tags except the XML declaration and the DOCTYPE, which are special. There may be other special tags, but if so I am not aware of them. They would have to start with a non-alphanumeric character (e.g., a ! like the doctype or a ? like the XML declaration) in order to prevent their being parsed as regular XML tags.

The third form is the most minimalist, but it creates problems for certain legacy browsers, so one of the first two approaches is recommended. Which one depends on whom you ask. They are equivalent if the program parsing them is compliant.


for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}

Replies are listed 'Best First'.
Re: Re: br tag in CGI.pm V2.91
by kal (Hermit) on Apr 10, 2003 at 18:05 UTC

    If it's a legacy browser, it shouldn't have X/HTML delivered to it - I suspect what cLive ;-) is doing is delivering X/HTML as HTML, which would cause Mozilla to go into tagsoup mode (i.e., you're not in strict or even transitional, you're in nothing).

    I tested my Moz, and <br/> is equivilent to <br></br> in an X/HTML document delivered as such. For HTML documents, <br> is the only valid markup - <br/> won't work, and <br /> is invalid HTML (although they do suggest it in the XHTML spec as some kind of backward compatible thing, which is wrong IMO).

    Such is life :( I tend to deliver valid X/HTML to those clients that can handle it, and tagsoup to the rest.