Whats the correct XML and html declarations for xhtml strict?

whats the correct XML and html declarations for xhtml strict ?

Is this right ?

<?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” xml:lang=“en” lang=“en”>

Do you have similar demos for the thousands of possible uses for XHTML that do not involve a web browser? There is no point in using XHTML if you are only targetting web browsers. XML has millions of possible uses and with XHTML being a version of XML it can be transformed for any of those uses. As such you cannot guarantee that the DOM will be available before the entire content has been processed anywhere other than in a web browser. So to gain any benefit from using XHTML you have to assume that not all of the places it is used will necessarily make parts of the DOM available prior to it loading completely unless you are just targetting web browsers (in which case an HTML 4 strict doctype is more compatible than an XHTML one)

Now? Now you stay with HTML 4.01 and keep an eye on HTML 5. When enough web browsers support HTML 5 (which should soon include IE 9), that will then be a good time to transition over to that one.

There’s no reason why the DOM can’t be built incrementally in non-browser environments. In fact, SAX is a streaming event-based API without a tree to expose the structure of a document to the application while it is being parsed. If XML required the whole document to be represented in memory before exposing it to the application then it would be hugely inefficient.

As for a demo, http://validator.nu/ uses a streaming parser (for both HTML and XML) and checks the document structure against schemas and run custom checks in Java without waiting for the whole document to be parsed. You can read about it here: http://hsivonen.iki.fi/thesis/html5-conformance-checker (see chapter 5).

what about now?

XHTML 2 has been abandoned since work started on HTML 5 and so XHTML is NOT the future way of designing web pages.

I’m leaning towards html4 strict but are we only talking about changing minor areas in you document to do either, I mean the trick here is separating markup from style, if I keep that a much as I can , i’ll be able to do either, or is it not as simple as that.

mmmmmmmmmm its a bit like choosing who your going to vote for isnt it ? you sort of believe none of them, and all of them at the same time. and just like voting i’m inclined to go with the one with the flashy badges, “Felgal” but hey, so did George Bush and Adolph. NOT REALLY FELGAL , NO IMPLICATIONS MEANT, JUST A METAPHOR NOT A SIMILE.

In response to the “You have had your question already answer several times” . Do you know how an old interigation technique works ? It ask the same question in several different ways to get the truthfull answer ?

This is not correct. The DOM is available to scripts during parsing also for XHTML. I don’t know how to convince you of this other than saying that I do quality assurance for a browser vendor for a living, but you already know that. Maybe I can show you a demo.

data:application/xhtml+xml,<html xmlns='http://www.w3.org/1999/xhtml'><head><script>var log = []; var elms = document.getElementsByTagName('*'); log.push(elms.length);</script></head><body><script>log.push(elms.length)</script><p><script>log.push(elms.length); document.body.textContent = 'number of elements during parsing: ' + log.join(', ');</script></p></body></html>

Result in Opera, Firefox and Chrome:

number of elements during parsing: 3, 5, 7

so do I still design for xhtml strict and work backwards or do I just design to html4 strict. The post isnt about javascript or the dom, I can do that with xhtml anyway ,as I just let people have what they want, images text , video and data collection, to a strict xhtml valid document, I design cool graphics which is more than most people get. the pages load mega quickly , there easily read by google. WHAT DO I DO ?

it just my confusion as to whether there is a standard way to design now or not. Forgivve me but your having your own conversation here.

thanks xhtmlcoder, so I just design to xhtml, tell the client its the nuts, then wait for them to say , its not working in netscape 0.1 what needs to be done, rather than covering every eventuality in the first place. I just want to not look like a pratt in front of my clients, when I say xhtml is the future way of designing web pages , its relativley future proof. then explain.

Okay, you have convinced me. If I remember correctly the reason I thought that it had to wait for the entire DOM first was because a lot of different books that I had read said that it did. Obviously those books were wrong.

Classic feedback.

Today I remembered an article that all self-respecting web designers ought to be aware of. The article appeared in A List Apart; it was written by a Brit called Jeremy Keith; and it introduced (or highlighted) the concept of behavioral separation.

Here’s the link to the article.

Allow me to quote…

[I][COLOR=“Red”]Now that I’ve written my function, all I have to do is run it. But there’s a problem. I can’t simply execute the function like this:

prepareGallery();

If I do that, the function—which is in an external file or in the head of my document—will run before the rest of the document has finished loading. The DOM methods won’t work because there won’t be any Document Object Model. Without a complete document, there can’t be a corresponding model.

I need to wait until the entire document has finished loading. Fortunately, the loading of the document triggers an event, namely the load event of the window object. I can use the corresponding onload event handler, window.onload, to assign the prepareGallery function to this event.[/COLOR][/I]

With normal HTML, though, it is possible to use the document.getElementById.getElementsByTagName method before the page has loaded in its entirety, provided (of course) that the element you are attempting to access has already loaded.

Since real XHTML (served as an application of XML) is commercially impossible, due to the ubiquity of Internet Explorer (and XML’s unsuitability for web pages), this is most likely a moot point, Andrew.

As long as you serve it as text/html it doesn’t matter one iota whether you use an XHTML or an HTML doctype declaration. It will be parsed, interpreted and rendered as HTML anyway. CSS will apply according to HTML rules. JavaScript/DOM will apply according to HTML rules, and that includes using an HTML DOM (uppercase node names, etc.), no XML namespaces, case insensitivity in document.getElementsByTagName(), and so on.

So unless you really serve your XHTML markup as an application of XML, you can simply forget about this.

Thanks for that. Perhaps I misunderstood Stephen’s comments.

But I do recall Stephen (or possibly someone else) saying that the DOM can’t be traversed in XHTML until the entire page has been loaded.

Then again, maybe I misread that part, too.

Hey, maybe I was pissed!

If you are writing web pages that need to be processed by IE then use HTML 4.01 strict which is the latest version of HTML.

If you have a non-web application that is using XHTML then you will not need to worry about IE not supporting it so it will not be a problem.

There are plenty of XHTML commands that can only be understood by programs specifically designed to handle XHTML. There is only a very restricted subset of XHTML that can be interpreted as HTML. Also any JavaScript to work with XHTML will be completely different from JavaScript to work with HTML.

For example this perfectly valid XHTML statement will not work as HTML but is the correct way to attach a JavaScript file to XHTML.

<script type=“application/javascript” src=“myscript.php”/>

If you write XHTML and serve it as text/html, which is what Internet Explorer demands, the web browsers will be interpreting a funny-looking HTML that looks like XHTML.

But, that seems to be the way that things are done these days.

You have two choices.

  1. Write in strict XHTML but limit what you write to only that which HTML is capable of supporting.

  2. Write in strict HTML and accept that things are the way they are.

It seems that the web browsers this time around are providing a much more even-handed support for HTML5, so writing HTML4 while you prepare for HTML5 seems to be a good choice right now.

ok, How do I please ie and the wc3 recommendations for strict xhtml. whats the right way ? Do I write xhtml strict pages and use a html 4 strict declaration or do I use the fix with the extra file.

ALL I WANT TO DO IS WRITE PAGES THAT ARE BACKWARD COMPATABLE AND ARE STRICT XHTML AS RECOMMENDED BY THE BIG GUYS, IS THAT RIGHT OR WRONG . I’M TRYING TO MOVE OVER FROM TABLES , 1X1 SPACERS AND OLD SCHOOL EVERYTHING GOES TO THE MORE STRUCTURED WAY OF WITING PAGES FOR GOOGLE AND SPEED OF LOAD , GOOD SEO ETC. SO WHATS THE RIGHT WAY TO WRITE PAGES. XHTML STRICT , TRASITIONAL , WHATS IDEAL. AGAIN WHO DO YOU BELIEVE.

Excellent post bro, but with all respect I think I’ll wait until the legendary Stephen Felgall chips in. I’m sure it was he who clarified this issue not so long ago.

Like a lot of other bums on this forum, I switched to XHTML when it became apparent that this was the next “big thing”. It wasn’t until reading that Dave Shea article (referenced above) that I saw the error of my ways. Dave went back to HTML4; I bravely ventured forward and switched to HTML5. But that’s another story.

Soon – very soon – I need to go back and improve some of the sites I made during my XHTML phase. So if anyone (especially Lord Felgall of Sydney) can throw a little more light on this topic then I will be extremely grateful.

I think that it depends on if the XHTML code is properly served (rare) as application/xhtml+xml, or served in its more common text/html habitat.