Where is the error?

C

cwdjrxyz

The key is that everything in xml must be closed. Thus both <br> and </br> considered alone are correct, but in xml they must be used as the
pair <br></br> to satisfy that everything is closed.
Unfortunately this confused some browsers when xhtml first came out,
as <br> does not have to be closed in html.. Hence <br /> was used as
combined open and close break since it did not confuse some browsers of the era.
It also is a bit less to type than <br><br />
 
C

cwdjrxyz

Correction: It also is a bit less to type than <br></br>.

I have a xhtml 1.1 test page at http://www.cwdjr.net/video7/test3break.php
which uses <br></br> 8 times in a division at the top of the page to
push the image down quite a bit. The page without the 8 unneeded
breaks is at http://www.cwdjr.net/video7/test3.php . Both pages
validate at the w3c. I viewed the page with 8 <br></br> pairs on IE 9
release candidate(replaced beta on Feb10) and the most recent versions
of Firefox, Opera, Seamonkey, Safari for Windows, chrome, e-meleon,
and flock. All showed the effect of the breaks correctly. Thus for the
most recent browsers I tested, there is no problem with using <br></
br> in xhtml 1.1. If you go back enough years (up to about 10), you
may find a problem with some browsers. If any of you collect old
browsers that are xhtml capable, it would be interesting to know which
browser versions have problems with <br><br>. I likely will continue
using <br /> out of habit and in case some not-so-ancient browsers
turn out to have problems with <br></br>.
 
M

Mayeul

None of the constructs was the one under discussion, namely <br/>, which
you claimed to be "perfectly correct".

The parts that you quoted (but perhaps didn't read) say that <br/> is
not OK, or "perfectly correct" to use your words, by the specifications.

The compatibility guidelines do indeed advise against the use of <br/>
for backward compatibility reasons.
This section is however informative, not normative.

When in a situation where you are confident you need not to worry about
backward compatibility (which you are in practice with any browser I
could manage to run this year,) then <br/> is perfectly correct as per
the specification in that:
- XHTML is defined as an XML format
- the DTD indicates that br elements may, and actually must, be empty.

Now due to compatibility guidelines and actual everlasting backward
compatibility, saying that <br/> is perfectly correct in the general
case is probably an overstatement.
 
J

Jukka K. Korpela

Mayeul said:
When in a situation where you are confident you need not to worry
about backward compatibility (which you are in practice with any
browser I could manage to run this year,) then <br/> is perfectly
correct as per the specification [...]

I haven't seen any recent study on browser behavior in this issue, and maybe
the topic isn't that interesting (who needs to save a few spaces anyway?).
But as a general reminder, browsers aren't the only thing to worry about.

On the Internet, nobody knows you're a robot. Maybe an old robot that does
not want to learn new tricks.

Besides, web page editing software, spelling checkers, and all kinds of
software that you might make to process HTML documents cannot be expected to
be up to all the applicable specifications. Such tools might have their
origins in the 1990s and therefore sloppy and odd parsers.
 

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

Members online

Forum statistics

Threads
473,797
Messages
2,569,648
Members
45,381
Latest member
TomasLnx34

Latest Threads

Top