html vs. xhtml

W

wexfordpress

I know that many books (I bought a few) think that xhtml plus CSS is
the way to go. But in the real world what are people using on
websites? For the one person shop is there any advantage to learning/
using xhtml? I have looked at it and was underwhelmed. It seems to
increase the density of tags per page without compensating benefits.
But I am willing to be convinced otherwise. I need to know where I
need to invest my learning time.

I will be doing my own sites at least to start. I already know some
html.

John Culleton
 
V

viza

Hi

I know that many books (I bought a few) think that xhtml plus CSS is the
way to go. But in the real world what are people using on websites? For
the one person shop is there any advantage to learning/ using xhtml?

xhtml has no advantages and several minor disadvantages compared to html4.

The idea was "let's publish a more-or-less identical standard but this
time tell browser developers that they must refuse to display pages that
are not well-formed". Mozilla even did that for a little while!

When Microsoft decided not to do the same in Internet Explorer they dealt
the kiss of death to xhtml, and really the w3c should have known that
that would happen.

The net outcome of the whole affair is that a lot of people now put
superfluous slashes in their br element tags.

From your point of view as a prospective designer there is no
particularly big reason not to use xhtml.

Personally I like being able to implicitly close my paragraph elements,
(omit </p>). Perhaps you might feel the same, or you may feel that it is
easier to close every element explicitly. If you use xhtml you are saved
from learning which tags are forbidden or optional, but you have to do a
tiny bit more typing.

The features and usefulness of the two are completely identical in the
real world, your users will not be able to tell the difference.

The following doesn't really affect your decision, but you may be
interested: xhtml is a massive pain in the arse to browser developers,
or anyone who has ever tried to write programs to get information out of
web pages. (I have in several languages). Some of the problems are:

- Parsing xml is not difficult, (it is trivial), but many idiot
developers think that it is cool to put a few xml empty element tag
slashes in their pages. Not all the way through, mind, just a few.

- Changing the content model of elements like script makes it quite
complicated to put any content in them at all (I recommend only ever
using external scripts and styles) and this makes it pure guesswork to
try to get any information out of them.

- The fact that xml is not up to the job of html means that after you
parse a table in xhtml you then have to piss around with the tree
putting the tbody in, which would have been implied by an sgml parser.

My only real advice is to pick one, learn it well, and stick to it
consistently.

HTH
viza
 
S

Stanimir Stamenkov

Tue, 08 Jul 2008 19:15:00 GMT, /viza/:
The idea was "let's publish a more-or-less identical standard but this
time tell browser developers that they must refuse to display pages that
are not well-formed". Mozilla even did that for a little while!

Mozilla, Opera and Safari still do that for pages served up as
application/xhtml+xml (and any XML type, for that matter). I
remember Opera once rendered the page up to the first
well-formedness error, then an error message as part of the content,
but with Opera 9.5 (may be with Opera 9.2x, too) it only shows the
error message (and link to "Reparse document as HTML"). Safari 3.1
renders an error message as part of the content, at the very top,
and then displays the content up to the first error, but that's o.k.
according to the XML specification:
*fatal error*

[Definition: An error which a conforming XML processor MUST
detect and report to the application. After encountering a fatal
error, the processor MAY continue processing the data to search
for further errors and MAY report such errors to the application.
In order to support correction of errors, the processor MAY make
unprocessed data from the document (with intermingled character
data and markup) available to the application...
 
D

dorayme

viza said:
xhtml has no advantages and several minor disadvantages compared to html4.

The idea was "let's publish a more-or-less identical standard but this
time tell browser developers that they must refuse to display pages that
are not well-formed".

More or less identical to what?
 
D

dorayme

viza said:
Personally I like being able to implicitly close my paragraph elements,
(omit </p>). Perhaps you might feel the same, or you may feel that it is
easier to close every element explicitly. If you use xhtml you are saved
from learning which tags are forbidden or optional, but you have to do a
tiny bit more typing.

Fair enough in a way. But OP needs to know that even using HTML 4.01 he
can be easily alerted to non closing paragraphs (optional as they may
be) from a good editor and there even ways to make sure this is part of
the standard of a tailor made document type.

In other words, don't choose XHTML because you prefer to be close tags.
 
D

dorayme

Guy Macon said:
For someone who just wants a good
web page, HTML 4.01 strict is the obvious choice.

It is not the obvious choice at all in the light of the massive weight
of (uninformed) opinion. However it is the best choice.
 
V

viza

But HTML is not "well-formed" markup. That is why "<br />", "<img ...
/>" and similar constructs exist.

<obi wan>
Aah, naive young child of the XML generation. Do you really think that
the term "well-formed" came about when the botchers dreampt up XML? The
term has an equivalent meaning in SGML, but in SGML, </br> is forbidden.

An html document can be perfectly well formed without any of
<html><head><body></head></body></html></p> etc, etc, and if you write
<br/> in html, it means a break element follower by a literal slash and
greater that sign in the text.
 
C

cwdjrxyz

I know that many books (I bought a few) think that xhtml plus CSS is
the way to go. But in the real world what are people using on
websites? For the one person shop is there any advantage to learning/
using xhtml? I have looked at it and was underwhelmed. It seems to
increase the density of tags per page without compensating benefits.
But I am willing to be convinced otherwise. I need to know where I
need to invest my learning time.

I will be doing my own sites at least to start. I already know some
html.

Many people likely would benefit most by concentrating on html 4.01
strict along with css at first. Once you can write xhtml 4.01 strict
well, It is very easy to convert to xhtml if the need or desire should
arise. Be aware that there are two aspects of xhtml to consider, being
writing the correct code and serving it correctly. I would guess that
perhaps 99% of xhtml code you see is not served correctly. True xhtml
is served as mime type application/xhtml+xml, which must be set on the
server paired with an extension such as .xhtml or .xml since .html
already is paired with mime type text/html on most servers. If you
serve xhtml as html, it usually will work, but there are absolutely no
benefits and you would be better off using html 4.01 strict in the
first place. If you serve xhtml with the correct mime type, it can not
be viewed on any Microsoft IE browser, at least up through IE7. In
that case you have to use some tricks, using header exchange or
something else to serve xhtml to browsers that say they will accept it
and html to browsers that say they will not in the header exchange.
This often involves a script on the server such as php. Most popular
recent non-IE browers such as Firefox, Opera, Safari, and Seamonkey
will handle true xhtml properly. They parse an xhtml phage as xml and
will tolerate nearly no xml errors. Many small devices depend on xml
these days, and writing code that can be handled by xml devices is
very important in some specialized areas.

The next most useful things to learn after html and css for many would
be JavaScript and some server side script such as php.
 
A

Andy Dingley

The only real reason to have a site in XHTML is if the markup is
generated by XSLT from a common source of content in XML.

No, this is a popular misconception.

There's some argument for using XHTML internally, if you're making use
of the easy access to XML-based tools. These same tools (most
obviously XSLT) make it simple to publish this to the web as HTML,
rather than XHTML.

XHTML is problematic on the web. You can do it, but you either
shouldn't, or should do it (at most) cautiously and with the
application of significant skill. As it's easier to make HTML from
XSLT than to make XHTML for XSLT (good practice web-friendly XHTML),
then publish to HTML.

"Head First HTML with CSS & XHTML" is the best HTML tutorial book
around and has good treatment of this HTML/XHTML issue.
 
M

marchinram

I know that many books (I bought a few) think that xhtml plus CSS is
the way to go. But in the real world what are people using on
websites? For the one person shop is there any advantage to learning/
using xhtml? I have looked at it and was underwhelmed. It seems to
increase the density of tags per page without compensating benefits.
But I am willing to be convinced otherwise. I need to know where I
need to invest my learning time.

I will be doing my own sites at least to start. I already know some
html.

John Culleton

xhtml is nice because you can use features like namespaces to reuse
elements in your pages. Also, since xhtml will be parsed like xml and
not be as forgiving as html with syntax errors, it loads much faster,
the renderer doesn't have to try and interpret what you meant.
 
V

viza

Hi marchinram

since xhtml will be parsed like xml and not be as forgiving as html
with syntax errors, it loads much faster

Sorry but that's just not true, because (a) Strict sgml parsers are
available. (b) Any real-world www browser simply has to have to have a
tag-soup parser, and (c) The difference in speed between parsers will not
be noticeable in any case (on anything more powerful than a 1980s
wristwatch).
the renderer doesn't have to try and interpret what you meant.

Sorry again but that has nothing to do with xhtml vs. html. All browsers
that have a "standards mode" can use it with xhtml or html, and all
browsers that have a tag-soup parser can and do end up using it on pages
that are marked as either, but conform to neither.

viza
 
C

cwdjrxyz

Many people likely would benefit most by concentrating on html 4.01
strict along with css at first. Once you can write xhtml 4.01 strict
well, It is very easy to convert to xhtml if the need or desire should
arise. Be aware that there are two aspects of xhtml to consider, being
writing the correct code and serving it correctly. I would guess that
perhaps 99% of xhtml code you see is not served correctly. True xhtml
is served as mime type application/xhtml+xml, which must be set on the
server paired with an extension such as .xhtml or .xml since .html
already is paired with mime type text/html on most servers. If you
serve xhtml as html, it usually will work, but there are absolutely no
benefits and you would be better off using html 4.01 strict in the
first place. If you serve xhtml with the correct mime type, it can not
be viewed on any Microsoft IE browser, at least up through IE7. In
that case you have to use some tricks, using header exchange or
something else to serve xhtml to browsers that say they will accept it
and html to browsers that say they will not in the header exchange.
This often involves a script on the server such as php. Most popular
recent non-IE browers such as Firefox, Opera, Safari, and Seamonkey
will handle true xhtml properly. They parse an xhtml phage as xml and
will tolerate nearly no xml errors. Many small devices depend on xml
these days, and writing code that can be handled by xml devices is
very important in some specialized areas.

The next most useful things to learn after html and css for many would
be JavaScript and some server side script such as php.

Since some may not have seen a properly served xhtml page and what
happens when it has a error when parsed as xml, I have 3 demo pages:

http://www.cwdjr.info/test/formtestX.xhtml (xhtml page served
properly with mime type application/xhtml+xml)

http://www.cwdjr.info/test/formtestXerror.xhtml (xhtml page same as
above with one paragraph not closed)

http://www.cwdjr.info/test/formtest.html (html 4.01 page served with
mime type text/html)

These are just simple test pages of a form. The form does not link to
anything. IE browsers up through at least IE7 will view the html 4.01
page as expected, but not an xhtml page served properly. In this case
it give you a view of the source code in color rather than the
contents of the page. An xml type is optional just above the Doctype
for the page. If this is used, IE gives up completely. The most recent
versions of Firefox, Seamonkey, Opera, and Safari for Windows all
display the xhtml page properly. Even a very old Amaya browser does
also. What you get varies somewhat from browser to browser when you
try to view the test page with an error. All detect a very serious
parse error in the xhtml page that does not close one paragraph. And
this is proper, because not having something closed is one of the most
serious errors you can make in xml since the whole basic structure of
xml is based on having everything that is opened closed.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top