Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Need some clarifications on xhtml

Reply
Thread Tools

Need some clarifications on xhtml

 
 
Thierry Lam
Guest
Posts: n/a
 
      09-28-2006
I've decided to switch to xhtml and I've added the following at the top
of my page:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


However, my page is still working and I can't see any warnings whenever
I use old html tags like <br> instead of <br/>. What other things
should I add to validate xhtml tags?

 
Reply With Quote
 
 
 
 
jojo
Guest
Posts: n/a
 
      09-28-2006
Thierry Lam wrote:

> I've decided to switch to xhtml and I've added the following at the top
> of my page:


Why?

>
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>


Where do you expect the warnings to appear? Definetly not in the
browser... (except you use some firefox extension or something similar)

>
> However, my page is still working and I can't see any warnings whenever
> I use old html tags like <br> instead of <br/>. What other things
> should I add to validate xhtml tags?
>


A XHTML document should look like this:

<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- page head -->
</head>
<body>
<!-- page body -->
</body>
</html>
 
Reply With Quote
 
 
 
 
cwdjrxyz
Guest
Posts: n/a
 
      09-28-2006

Thierry Lam wrote:
> I've decided to switch to xhtml and I've added the following at the top
> of my page:
>
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>
>
> However, my page is still working and I can't see any warnings whenever
> I use old html tags like <br> instead of <br/>. What other things
> should I add to validate xhtml tags?


Go to http://validator.w3.org/ to validate a page as any of several
forms of html/xhtml including the one you mention. The break tag you
mention usually is written with a space included in it as <br />. I
believe this was done to avoid problems with some browsers. In general
all tags have to be closed in xhtml. When tags such as br and img that
have no close tag in html are used they most be closed as was done for
br above such as <img blah />. Closing p is optional in html. In xhtml
a paragraph must always use a closing tag </p> in addition to the
opening tag <p>. Unless you set up your server to serve true xhtml
using an extension such as xhtml and associating a mime type with it
such as xhtml+xml, the page will just be served as text/html despite
your xhtml tags and Doctype. Note the page will still validate as xhtml
if there are no errors. The validator just checks the code for what you
ask. However if you use the advanced interface to validate, there will
be additional information showing you how the page is served. Recent
Firefox, Netscape, Opera, and a few other browsers can handle xhtml
served correctly as such. However IE6 will not, and you can not view
the page. You have to provide IE6 and a few older browsers with an html
4.01 strict page using some server side code or whatever to allow
viewing of the page by them. Unless you do all of this, there is no
point in writing the page in xhtml if IE6 and some older browsers are
intended to be viewed with it. Unfortunately it appears that not even
IE7 will handle true xhtml. It is quite possible to serve even xhtml
1.1 correctly. However, to do so, you have your work cut out for you
and much to learn, likely including some server side languages.

When a page is properly served as xhtml is viewed with a browser that
can handle it, the browser becomes as strict as a mother superior in a
1800s convent. Tiny code errors that would cause little or no harm on
an html page often cause the browser to give you an error message
rather than a view of the page. Unless one writes very good html 4.01
strict, don't even think of writing xhtml and serving it properly as
such.

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-28-2006
Scripsit jojo:

> Thierry Lam wrote:
>
>> I've decided to switch to xhtml and I've added the following at the
>> top of my page:

>
> Why?


I guess the usual explanation is that people have no idea of XHTML or its
practical usefulness or uselessness, but someone told them it's the "newest
recommendation".

> Where do you expect the warnings to appear? Definetly not in the
> browser...


Actually, a browser _could_ have a validating XML parser. That was really
more or less part of the idea. Of course, that would not mean warnings but
error messages.

> A XHTML document should look like this:
>
> <?xml version="1.0" ?>


Well, in theory it could start with the <?xml ...> declaration, but in
practice, that throws IE to "quirks mode", making it simulate some errors of
IE 5. How modern...

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      09-28-2006
Jukka K. Korpela wrote:

>> <?xml version="1.0" ?>


> Well, in theory it could start with the <?xml ...> declaration


.... although it might be forbidden in XHTML documents served as text/html
(its hard to say for sure, the spec is rather fuzzy regarding the subject
and I prefer to avoid it altogether by using HTML 4.01 on the client side
for webpages except where XHTML provides an actual practical benefit).

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
jojo
Guest
Posts: n/a
 
      09-28-2006
Jukka K. Korpela wrote:

>>> I've decided to switch to xhtml and I've added the following at the
>>> top of my page:

>>
>> Why?

>
> I guess the usual explanation is that people have no idea of XHTML or
> its practical usefulness or uselessness, but someone told them it's the
> "newest recommendation".


Yeah, I suppose that's the reason. But unfortunately the "newest" is not
always the best recommendation (Not that the idea behind XHTML is bad,
it's just the poor support in "modern" browsers which is...)

>> Where do you expect the warnings to appear? Definetly not in the
>> browser...

>
> Actually, a browser _could_ have a validating XML parser. That was
> really more or less part of the idea. Of course, that would not mean
> warnings but error messages.


Right, it could have one. But most browsers have none or do only use it
on properly served XHTML documents (Which means the MIME-type is set to
application/xhtml+xml and not text/html). And I guess the MIME type is
not set properly...

>> A XHTML document should look like this:
>>
>> <?xml version="1.0" ?>

>
> Well, in theory it could start with the <?xml ...> declaration, but in
> practice, that throws IE to "quirks mode", making it simulate some
> errors of IE 5. How modern...
>

Oh, yes, I remember... the quirks mode is enabled if there is no Doctype
(with URL, the ones without enable quirks mode ASFAIK) specified in the
*first* line of a html document...

But there maybe is another problem with the xml declaration: if php is
available on the server and short-tags are enabled the <? is recognized
as beginning of a php-statement...
 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      09-29-2006
jojo wrote:

> But there maybe is another problem with the xml declaration: if php is
> available on the server and short-tags are enabled the <? is recognized
> as beginning of a php-statement...


The solution of course is:

<?= '<?xml version="1.0" ?>'."\n" ?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      09-29-2006
jojo wrote:

> A XHTML document should look like this:
>
> <?xml version="1.0" ?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


What's an "XHTML document" ? If you mean a local XML document, then
why not use XHTML 1.1 ? If you mean a web-published document then for
certain you need to lose that XML declaration:
<?xml version="1.0" ?>
as it breaks far too many web user agents.

> <html xmlns="http://www.w3.org/1999/xhtml">


If you're going to pontificate, make sure you're infallible.

Where are the lang and xml:lang attributes ?

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      09-29-2006
Scripsit Andy Dingley:

> If you're going to pontificate, make sure you're infallible.
>
> Where are the lang and xml:lang attributes ?


Are _you_ trying to pontificate that the lang and xml:lang attributes are
required? Surely not by the syntax, or by any HTML specifications.

Language markup might good practice, but it has fairly little practical
value. Programs don't use the language information expressed that way very
much, partly because the information is so often plain wrong.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: smart pointer clarifications Phil Bouchard C++ 3 08-23-2008 07:03 PM
[70-297] Domain restructuring / upgrading clarifications M D MCSE 13 01-12-2007 08:14 AM
[.NET 1.1] Authentication and cookies clarifications Nicola Farina ASP .Net 2 01-22-2006 01:53 AM
rtp clarifications needed John VOIP 0 12-14-2005 03:08 PM
SIP clarifications? Still Hunting VOIP 2 10-12-2004 04:39 AM



Advertisments