...

View Full Version : What is difference between XHTML 1.0 and XHTML 1.1?



ampulator00
09-30-2004, 06:07 AM
What is difference between XHTML 1.0 and XHTML 1.1? And why should I use XHTML over HTML 4.01?

ronaldb66
09-30-2004, 09:26 AM
XHTML 1.0 is basically a reformulation of HTML 4.01 as an XML application, incorporating most of HTML 4.01, but using the stricter syntax and forming rules of XML. For instance, where HTML 4.01 allowed many container elements not to be closed by an end tag, XHTML 1.0 requires all elements to be closed properly.
Another syntax difference is the requirement to put attribute values inside quotes, and to fully specify attribute/value pairs instead of abbreviations.

XHTML 1.1 is the first XHTML version where modularisation is applied, forming the basis for a whole family of different XHTML "flavours". Where XHTML 1.0 still came in Strict, Transitional and Frameset versions, XHTML 1.1 is basically only available as Strict.

you can read all about this at the W3C HTML homepage (http://www.w3.org/MarkUp/).

gohankid77
09-30-2004, 01:21 PM
XHTML 1.0 (Strict) - Allows the name and lang attributes for some elements but is still better-formed than HTML. It was basically a transition to true XHTML.

XHTML 1.1 - Only allows the name attribute on form elements and the xml:lang attribute completely replaces the lang attribute. This is very close to true XHTML as we know it so far.

XHTML 2.0 - Looks promising. This seems like it will be a very good recommendation. Hardly any presentational elements, which means CSS3 will also be released a bit before/after to help. This'll be nice.

bradyj
09-30-2004, 04:59 PM
XHTML 2.0 - Looks promising. This seems like it will be a very good recommendation. Hardly any presentational elements, which means CSS3 will also be released a bit before/after to help. This'll be nice.

The only issue with XHTML 2.0 is that it will not be backwards compatible -- which may be needed to push things forward and stop using old methods. The object tag will make a huge comeback, as well as the img tag will be gone and replaced with something more clean to allow for better image replacement techniques... in short, everything can be an image:


<h1 src="image.png">My header</h1>


If the browser can take the image, it will -- if it cannot, it will just take the text. You could also save gifs, jpegs, or pngs of the same thing and do:


<h1 src="image">My header</h1>


The browser would then choose which format serves a better purpose. There will be many other changes, but I thought pointing that out would be worth it.

I just wanted to emphasize xhtml 2, but everyone got 1.1 right, it's just an improved hardened version of xhtml 1.0, with everything being strict.

liorean
09-30-2004, 05:19 PM
Don't forget that one of the biggest differences between XHTML1.1 and XHTML1.0 is that XHTML1.0 MAY be sent as 'text/html' if it conforms to appendix C (and not in any other case) but SHOULD be sent as 'application/xhtml+xml', while XHTML1.1 SHOULD NOT be sent as 'text/html' and as it seems XHTML2.0 when released MAY NOT be sent as 'text/html'.

AaronW
09-30-2004, 07:07 PM
It's also been suggested (http://www.hixie.ch/advocacy/xhtml) that authors should be using HTML 4.01 Strict if they aren't willing to send as XML.

Personally, I use XHTML sent as text/html. I prefer writing XHTML, as it feels more strict. Heh. And it works.

mindlessLemming
09-30-2004, 10:22 PM
Personally, I use XHTML sent as text/html. I prefer writing XHTML, as it feels more strict. Heh. And it works.
Huh? :confused:
XHTML 1 isn't all that much more strict than HTML 4.01 Strict, and will ALWAYS result in larger file sizes. (All those trailing slashes add up!) I've finally admitted to myself that everything doesn't need to be xhtml, and it doesn't feel at all like a step back. If anything, it feels more like using the right technology in the right situation. At the end of the day, if you're not serving it properly (as liorean outlined) it is tag soup. That's why we put spaces before the trailing slash, so that our text/html soup doesn't kill the browser.

Most of us common folk have no need for XHTML, many of us never will. There, I said it. Deal with it. :eek: :D

]|V|[agnus
09-30-2004, 10:41 PM
While I agree that too many people think HTML is a dead language, I don't think the difference between XHTML 1.0 and HTML is that big. True, to send it as text/html is not perfect, but it IS acceptable as liorean pointed out, under the right circumstances.

Knowing that, I prefer to code XHTML because it is more consistent, the code is easier to read, and yeknow what's a factor in that? ---> /

But yeah... I like that all attributes must have a name and value, no minimized attributes.

*shrug*

Nothing wrong with HTML... but again, you CAN serve XHTML 1.0 as text/html. It's not "tag soup" just because it's sent with the improper mime type. Tag soup has to do with the quality and verbosity of the markup. My buddy Faruk Ates wrote a piece on this, in fact: http://annevankesteren.nl/archives/2004/08/tag-soup

liorean
09-30-2004, 10:45 PM
In fact, I would say that client side XHTML1.0 when conforming to appendix C only has three benefits over HTML4.01, all of which are cancelled when sending as 'text/html':
- Must be well formed, failing when encountering possibly ambiguous code.
- Can be handled by an XML only user agent.
- Can use XSLT in user agents that support it client side.

However, there are a number of benefits of instead using HTML4.01 and 'text/html':
- Smaller size because of optional tags and not needing to explicitly terminate empty elements.
- HTML user agents without XML or XHTML support may render it.
- SGML user agents with HTML recognition may render it.
- Fault tolerant, especially nice when you are not the sole content provider. (Ad services, user comments, automated content insertion from external sources, etc.)
- A slightly different object model and DOM handling, notably supporting document.write.

]|V|[agnus
09-30-2004, 10:52 PM
You guys lay out very good points in favor of HTML, and I've seen many before as well...

So, I'm left feeling frustrated and wondering why people push XHTML and even discuss how it can be sent properly when it seems that, when you split hairs, there's no way, that is if you want to have the most accessible document possible.

In short, I hate web development, and I quit.

gohankid77
09-30-2004, 11:08 PM
I was coding something for a friend in HTML 4.01 Strict just last night, and when I validated (this is local), the W3C Validator said that I had a </p> tag for which I had no opening tag. I was using a <pre> tag to show some code, and that was inside the paragraph (since it was a part of the explanation I was giving). Sure enough, when I took out the <pre> code, it validated! Here is an example:



<p>
text
<pre>
sample SGML
</pre>
</p>


I then realized that HTML isn't well-formed like XHTML (which is what I usually code in), so I removed the </p> tag, and it validated. Apparently, the Validator thought that it was a self-closing <p> tag, which is allowed in HTML. I'm changing it right now to XHTML 1.0 Strict since it isn't that long, yet.

Just a difference between HTML and XHTML. ;)

liorean
09-30-2004, 11:13 PM
Well, the benefits of XHTML over HTML pretty much all rely on one single thing: The document is XML. Things like embedding other XML languages (SVG, MathML etc.); supporting XML only user agents; forcing well formedness; using XSL, XML Shemas, XLink, XML DOM, XInclude, XPath, XPointer, XQueryX - they all are dependent on that single thing. If you remove the XMLness from an XHTML file, all you get is an invalid HTML file that takes more disc space than the corresponding HTML file would.

That given, it may be that there is some benefits to the XML format even when sent as 'text/html'. For example, the extra redundancy of XHTML as compared to HTML is easily eliminated by text based compression mechanisms such as gzip. The XML format is less ambiguous. I don't think I would recommend anyone but the already experienced HTML programmer to leave out optional tags, for instance. (I leave them out all the time, on the other hand...)

]|V|[agnus
09-30-2004, 11:14 PM
Ultimately, at this point I feel like I've learned enough about the differences and proper ways of serving either to be okay with serving XHTML 1.0 as text/html.

Why? For one, because the spec says it's acceptable, but also because there are *sooo* many little issues like this with web development right now that it seems nigh impossible to everything right no matter which way you turn.

The web is still fairly young, and these things will develop more and more. But the fact also remains that XML based markup is the future as things stand, and so I feel like XHTML is good practice.

I don't really hate web development... ;) My frustration with these issues and so many other areas of life stems from my desire for a black & white, well defined existence when the world simply isn't that way.

I think a little XHTML 1.0 served as text/html is not really all that high on any serious list of "problems".

gsnedders
10-01-2004, 12:15 AM
I'm sending it as application/xhtml+xml if the browser tells PHP that it accepts it, if it doesn't, it get's sent as text/html...

I've just updated the non-XHTML alternative it so it get's sent as text/html with the HTML 4.01 Strcit DTD...

gohankid77
10-01-2004, 01:26 AM
Just for a good reference:

HTML 4 - SHOULD be served as "text/html"; MUST NOT be served as "application/xhtml+xml", "application/xml", or "text/xml"

XHTML 1.0 (HTML compatible) - MAY be served as "text/html", "application/xml", or "text/xml"; SHOULD be served as "application/xhtml+xml"

XHTML 1.0 (other), XHTML Basic/1.1, XHTML+MathML - SHOULD NOT be served as "text/html"; SHOULD be served as "application/xhtml+xml"; MAY be served as "application/xml" or "text/xml"

SHOULD: Preferred
MAY: Not preferred, but still valid
SHOULD NOT/MUST NOT: Not preferred because it can really mess up your page


There you go! Have fun, and I hope this helps anyone who may have been misled or confused!

liorean
10-01-2004, 01:49 AM
I made a table for you in an earlier post for this. I didn't use MUST/SHOULD/MAY/MAY NOT/SHOULD NOT/ MUST NOT since I couldn't find complete references (XHTML and XHTMLC aren't placed in relation to SGML anywhere from what I could find) but it covers pretty much what you might want to know about mime types and document content language.

gohankid77
10-01-2004, 01:53 AM
Yeah, I knew it existed, but when I searched the forum, I used MUST, SHOULD, etc. and didn't find the table, so I just created a mini-guide. Creating a table was more time consuming.

AaronW
10-01-2004, 01:28 PM
I remember my reason for learning XHTML was that everyone on these boards was pushing it as the way of the future, and anyone posting sites written in HTML was told that they should go learn XHTML.

I think that most peoples' motivation was that XHTML was something new. HTML was boring and old. XHTML had an X in it which made it that much cooler. I kept using it because I liked the idea of closing everything. I'm very obsessive about constancy like that and the idea of <br> and <input> etc was always a bit troubling. But mostly, I just liked the X ;)

Now, obviously, I like it for being the way of the future and whatnot. The fact is, it WORKS as text/html. "Tag soup" or not. If I can inch myself that much closer to the forefront of technology without tripping everyone else, then you bet I will. It's just cooler being out front. Heh.

ampulator00
10-01-2004, 07:09 PM
Thanks for the info. :thumbsup: Which reminds me, What is XSL, and what I must put in a XML document to make it an XML document?

I also heard you can make your own DTD's or modules with XHTML 1.1. Is that true?

gsnedders
10-01-2004, 07:31 PM
XSL: http://www.w3schools.com/xsl/xsl_languages.asp


Customizing a DTD can be done quite easily... Once you know how :p


XML document: Put this at the beginning:
<?xml version="1.0" encoding="ISO-8859-1"?>Obviously replacing the encoding with whatever you need.

liorean
10-01-2004, 07:50 PM
Thanks for the info. :thumbsup: Which reminds me, What is XSL, and what I must put in a XML document to make it an XML document?

I also heard you can make your own DTD's or modules with XHTML 1.1. Is that true?

01. Q: What is XSL?
A: XSL is a set of two markup languages, XSLT and XSL-FO. XSL-FO is an entirely presentational markup language. XSLT is a markup language describing transformations to be done to one XML document to generate output. This output may be another XML language, or pretty much anything else. For example, you may have one XML document and three XSLT sheets. Each XSLT does different things, one transforms the data into a web page using HTML4.01. One transforms the document into an XSL-FO document for print. One transforms the document into a word document. Moz, iew and soon also saf has built in XSLT engines that can handle XSLT client side. Otherwise you typically use it server side.

02. Q: What must I put in an XML document to make it XML?
A: It is recommended that you use the XML declaration for all XML document. It is also recommended that you include a DOCTYPE declaration. A third recommendation is that you change all your stylesheet inclusions from any language specific syntaces to use the xml-stylesheet PI. You should serve it using either 'text/xml' (to-be deprecated and not recommended any longer), 'application/xml' or one of the 'xxx/yyy+xml' content types. (This is nothing you put into the file itself, however.)
If you are converting from tagsoup parsed HTML/XHTML to XML parsed XHTML, you should make sure this change is reflected in any <meta http-equiv="Content-Type" ... /> element in the document. You should of course make sure the file is well formed, but that normally fixes itself as any well formedness errors will lead to the browser halting.

03. Q: I also heard you can make your own DTD's or modules with XHTML 1.1. Is that true?
Yes. You must create a DTD for any extensions or not-commonly-used modules you want to use in your document, and if you wish you may use custom written modules. I suggest you read the XHTML1.1 and the M14n of XHTML technical reports on W3C on the topic.

ampulator00
10-01-2004, 08:58 PM
A third recommendation is that you change all your stylesheet inclusions from any language specific syntaces to use the xml-stylesheet PI.

How would I do that?

And whne you said XML declaration, do you mean:

<?xml version="1.0" encoding="ISO-8859-1"?>

liorean
10-01-2004, 09:15 PM
I mean that you should change <link ... /> elements into xml-stylesheet PIs. Have a look at Associating Style Sheets with XML documents (http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/).


The XML declaration is the <?xml ... ?>, yes.

ReadMe.txt
10-02-2004, 12:35 AM
I mean that you should change <link ... /> elements into xml-stylesheet PIs. Have a look at Associating Style Sheets with XML documents (http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/).


The XML declaration is the <?xml ... ?>, yes.

how well supported is this method of stylesheet linking however, because link tags are both vlaid and widely supported...

gohankid77
10-02-2004, 12:38 AM
<link /> is valid and quite useful, though @import is more highly recommended for style sheets.

gsnedders
10-02-2004, 12:41 AM
<link /> is valid and quite useful, though @import is more highly recommended for style sheets.

We're talking XML, not XHTML.

gohankid77
10-02-2004, 12:49 AM
Whoops, heh... Sorry... Didn't fully comprehend the previous posts. I didn't realize <link/> actually had a purpose in XML.


how well supported is this method of stylesheet linking however, because link tags are both vlaid and widely supported...


Valid? I thought the whole point of XML was to create your own tags and transform the XML document using XSLT! XML is always valid, right?

P.S. <?xml-stylesheet?> is better for XML. @import is better for (X)HTML.

gsnedders
10-02-2004, 12:53 AM
No, XML is bound by a set of rules, like any other language, not closing a tag would stop XML from being valid, your DTD might not be valid, etc. etc. etc.

ampulator00
10-02-2004, 01:35 AM
Hmm.... I'm currently making my web sites in XHTML 1.1, but I'm thinking about switching back to Html 4.01 Transitional just for a while, until I get either I get better at XML or XHTML, or learn how to make/modify my own DTD's.

gohankid77
10-02-2004, 01:48 AM
Heh... LOL

How do you get better by not practicing? I'm not trying to be mean or flame you or anything, but that was a complete contradiction IMHO.

ampulator00
10-02-2004, 03:12 AM
Heh... LOL

How do you get better by not practicing? I'm not trying to be mean or flame you or anything, but that was a complete contradiction IMHO.

Huh? who said that?

the issue is, I don't know much about DTD's, modules, or XSL yet, so I really have no use for XHTML or XML, for now.

AaronW
10-02-2004, 03:21 AM
HTML 4.01 Strict is absolutely perfect for most users, I'd say. XHTML as XML will give errors, but HTML isn't really that hard to write in the first place, so errors shouldn't be a huge problem. The problems arise when you're letting others add content, in which case XHMTL as XML becomes a huge pain, because one missing tag and that page gets turned into a big XML error. I'd say either use HTML 4.01 or use XHTML 1.0 Strict as text/html.

There anything wrong with an <hr /> in an HTML 4.01 document? Heh.

gohankid77
10-02-2004, 03:59 AM
There is a problem with using <hr/> (whether there is a space or not) and validating as HTML 4.01 Strict. You get a familiar error:



character data is not allowed here


If you use HTML 4.01 Transitional, it still doesn't validate:



end tag for element "HEAD" which is not open

document type does not allow element "BODY" here


You MUST use validate as XHTML if you wish to use the "/".

liorean
10-02-2004, 09:46 AM
The thing about the <... /> syntax is that '/' in HTML-as-SGML is a tag terminator. That means that <hr /> will be considered to be not one element hr, but instead one element hr followed by one text node >.

This is typically no problem, except for a few cases:
- As direct children to the head element, all empty tags using XML self termination notation will stop the document from validating.
- As direct children of the body element, all empty tags using XML self termination notation will stop the document from validating.
- As direct children of any other element that does not allow #PCDATA content, all empty tags using XML self termination notation will stop the document from validating.

This is one of the reasons why you, if you are sending the document as 'text/html', should use HTML4.01 instead of XHTML1.

gsnedders
10-02-2004, 10:11 AM
May I ask why this validates as HTML 4.01 Strict? [http://validator.w3.org/check?uri=http%3A%2F%2Ff1unleashed.com%2F&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&ss=1]

liorean
10-02-2004, 10:54 AM
If you turn on display of the parse tree, you might see the reason, and you might also see that ALL browsers except for DocZilla (and possibly Amaya) in SGML mode will parse it wrongly. If you then read my post above again you might catch the reason why it does validate - or rather, the reason why it does not fail to validate.

ReadMe.txt
10-02-2004, 11:09 AM
P.S. <?xml-stylesheet?> is better for XML. @import is better for (X)HTML.

Sorr to not clarify, i was meaning xhtml in my previous post. I would however disagree that @import is better for XHTML, since it must be used inside a style block it needs to be enclosed in a CDATA block, which will confuse older browsers unless you conditionally serve them along with your content header.

The main reason i see quoted for using @import is because the style is hidden from NS4, using media="screen" will do just that on a <link> tag, and you keep the option of using alternate stylesheets.

liorean
10-02-2004, 01:37 PM
1. Irrespective of whether you are using any other XML application or whether you are using XHTML, as long as you serve your document as XML you are recommended to use the xml-stylesheet PI instead of language specific methods of style association such as the link tag, the Link HTTP header, the meta element, the style element or the style attribute. The reason is that generic XML user agents are still capable of rendering the document.

2. There is no reason to prefer the @import way of stylesheet association to the link element or the xml-stylesheet PI if your document is served as XML. The browsers failing to render your stylesheet because you use @import doesn't handle XML anyway.

liorean
10-02-2004, 01:51 PM
Whoops, heh... Sorry... Didn't fully comprehend the previous posts. I didn't realize <link/> actually had a purpose in XML.link has no meaning in XML. It does in XHTML, however.

how well supported is this method of stylesheet linking however, because link tags are both vlaid and widely supported...Get your attributions in order, please. It was ReadMe.txt that said that, not I. As a response to that question, however, I can say that all browsers with XML support also supports the xml-stylesheet PI. There is to my knowledge one single browser that supports XHTML sent using 'application/xhtml+xml' that does not recognise it, and that is an inconsequential fringe-of-the-edge browser: MSN for OS X.
Valid? I thought the whole point of XML was to create your own tags and transform the XML document using XSLT!Oh, not quite. For the first, all XHTML documents are XML. For the second, XSLT is IMO highly overrated in usefulness, there are far better tools you can use if you necessarily want to transform your documents. But we've discussed the usefulness of XML to death already here on CF, so I won't get into that discussion again.
XML is always valid, right?Nope. It requires documents to be well formed, however, but that's entirely different from being valid.
P.S. <?xml-stylesheet?> is better for XML. @import is better for (X)HTML.Nope, see my last post in this thread on this.

gohankid77
10-02-2004, 03:31 PM
Heh... Sorry, about that liorean... I don't know what I was thinking...

That's a load to think about. Thanks for correcting so many of my mistakes.



An error is not a mistake until you refuse to correct it.
- unknown

ampulator00
10-02-2004, 05:51 PM
What do you mean by PCDATA and CDATA?

liorean
10-02-2004, 06:09 PM
CDATA means "Character Data" and PCDATA means "Parsed Character Data".
In XML, everything is PCDATA unless you explicitly wrap it in a CDATA block. However in SGML element contents may be CDATA or PCDATA depending on the element declarations in the DTD.

What is the difference between the two? Well, consider the input "&lt;p&gt;". In a PCDATA section that will be treated as a text node with the contents "<p>". However, in a CDATA section that will be treated as a text node with the contents "&lt;p&gt;".

Tails
09-26-2005, 12:34 AM
link has no meaning in XML. It does in XHTML, however.Get your attributions in order, please. It was ReadMe.txt that said that, not I. As a response to that question, however, I can say that all browsers with XML support also supports the xml-stylesheet PI. There is to my knowledge one single browser that supports XHTML sent using 'application/xhtml+xml' that does not recognise it, and that is an inconsequential fringe-of-the-edge browser: MSN for OS X. Oh, not quite. For the first, all XHTML documents are XML. For the second, XSLT is IMO highly overrated in usefulness, there are far better tools you can use if you necessarily want to transform your documents. But we've discussed the usefulness of XML to death already here on CF, so I won't get into that discussion again.Nope. It requires documents to be well formed, however, but that's entirely different from being valid.Nope, see my last post in this thread on this.

I could be mistaken, but as of recently, the CSS Validator at W3C has stopped recognizing the xml-stylesheet PI. I get a "No style sheet found" now (I believe it validated fine previously). There's been no announced updates to the CSS Validator, and nothing planned. Searching the archives, they've been planning to implement this PI since 2001. Has anyone else noticed this change?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum