SitePoint Sponsor |
|
User Tag List
Results 1 to 22 of 22
-
Sep 3, 2008, 11:51 #1
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
bit confused! bit of advice regarding the html / xhtml issue
hi all
been reading through all the FAQ'a and a couple of the latest threads.
What I don't understand is:
HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>test page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Why not just use:
HTML Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Do you just like working with the XHTML syntax, whats your views?
Or am I missing something?
Thanks cbThe more you learn.... the more you learn there is more to learn.
-
Sep 3, 2008, 12:04 #2
- Join Date
- May 2006
- Location
- Aurora, Illinois
- Posts
- 15,476
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
In a nutshell, XHTML was meant to be used as a markup language that worked with XML languages like SVG and MathML. And to be honest, you'd want to use a Strict DOCTYPE over a Transitional DOCTYPE anyway since the Transitional DOCTYPE was meant only to be used for sites "making the transition".
As for why people use XHTML when served as HTML instead of an XML app, it comes down to a number of things. Personal preference, ignorance, lack of knowledge about what XHTML really is, and so on.Save the Internet - Use Opera | May my mother rest in peace: 1943-2009
Dan Schulz - Design Team Advisor | Follow me on Twitter
SitePoint References: HTML CSS JavaScript | Become A Guru
WordPress SEO Checklist | What WordPress Plugins Do You Use?
Web Standards Curriculum | Image Free Equal Height Columns
-
Sep 3, 2008, 12:14 #3
Until very recently I was an ignorant person who thought xhtml was simply well formed html that was xml compliant.
When I have looked I almost always see an xhtml dtd served with webpages instead of html. Im guessing that maybe it is often misused.
-
Sep 3, 2008, 12:31 #4
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
And to be honest, you'd want to use a Strict DOCTYPE over a Transitional DOCTYPE anyway since the Transitional DOCTYPE was meant only to be used for sites "making the transition".
As for why people use XHTML when served as HTML instead of an XML app, it comes down to a number of things. Personal preference, ignorance, lack of knowledge about what XHTML really is, and so on.
So general speaking there is know difference then? besides what you mentioned above, that's if you just want to serve pure HTML? A suppose it's better in a way then if you're concerned about working to strict guidelines and keeping your code clean when running it through validation. yes?
And are you saying if I use the second example "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional" use strict here also?
Just trying to get a better understanding here. thanks!
When I have looked I almost always see an xhtml dtd served with webpages instead of html. Im guessing that maybe it is often misused.The more you learn.... the more you learn there is more to learn.
-
Sep 3, 2008, 12:36 #5
Or as I asked in another recent thread here. As suggested by someone else that a Mime type should be used, prehaps when serving xhtml-dtd use a Mime type also, to make it valid xml(as long as it validates as xhtml of course).
I just found a good article about it:
http://www.xml.com/pub/a/2003/03/19/dive-into-xml.html
-
Sep 3, 2008, 13:04 #6
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cheers cyjetsu. Anybody else on my last post? Thanks
The more you learn.... the more you learn there is more to learn.
-
Sep 3, 2008, 13:08 #7
relative information.
http://www.sitepoint.com/forums/show...=567415&page=3
-
Sep 3, 2008, 13:19 #8
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There is no technical benefit at all.
That's most likely a common reason, but Dan's suggestion that most people who choose to use an XHTML doctype don't understand the real differences is probably also an important factor.
There's a huge difference between real XHTML and HTML. There is no difference at all between pretend-XHTML and HTML, except that the former is invalid.
Strict is definitely recommendable over Transitional, since it promotes better practices (like separating content and presentation).
Yes. Use HTML 4.01 Strict:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Last edited by AutisticCuckoo; Sep 3, 2008 at 22:40. Reason: Rubbish advice removed
Birnam wood is come to Dunsinane
-
Sep 3, 2008, 13:58 #9
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Cuckoo
There is no technical benefit at all.
That's most likely a common reason, but Dan's suggestion that most people who choose to use an XHTML doctype don't understand the real differences is probably also an important factor.
There's a huge difference between real XHTML and HTML. There is no difference at all between pretend-XHTML and HTML, except that the former is invalid.
Strict is definitely recommendable over Transitional, since it promotes better practices (like separating content and presentation).
Is that the complete doctype you posted?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
One last thing
So it doesn't matter if I use 'Strict HTML 4.01' or 'pretend-XHTML' ? personal I would prefer Strict HTML 4.01 but they both do exactly the same thing besides a little difference in the syntax.
ThanksThe more you learn.... the more you learn there is more to learn.
-
Sep 3, 2008, 14:02 #10
- Join Date
- Dec 2004
- Location
- Sweden
- Posts
- 2,670
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Sep 3, 2008, 14:39 #11
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes thanks zcorpan.. "no"
but that's what we want isn't it? for all user agents to render in standards–compliant mode?The more you learn.... the more you learn there is more to learn.
-
Sep 3, 2008, 22:46 #12
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes.
There have been quite a few vociferous proponents for pretend-XHTML, and I'm sure they have convinced many unsuspecting victims. The whole thing about XHTML can sound very appealing to a beginner, especially if you conveniently omit the fact that it's not XHTML at all as long as it's served as HTML.
When served as HTML it must be parsed and interpreted as HTML. If you have a <meta/> tag or a <link/> tag in the document head, you're actually specifying a '>' character, which implies a <body> tag. The documents becomes invalid, but no one will notice since browsers have buggy parsers that let things like this slide.
Yes.
It does matter. If you use pretend-XHTML you'll have to make sure that it works both when served as HTML and when served as XHTML. There'll be some extra testing required.
You're right. I had a brain fart. That only applies for Transitional doctype declarations. Sorry for the confusion!Birnam wood is come to Dunsinane
-
Sep 5, 2008, 04:48 #13
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks a lot Cuckoo some good information here.
There have been quite a few vociferous proponents for pretend-XHTML, and I'm sure they have convinced many unsuspecting victims. The whole thing about XHTML can sound very appealing to a beginner, especially if you conveniently omit the fact that it's not XHTML at all as long as it's served as HTML.
If thats the case why is there so many jobs/job spec asking for XHTML? Is there any real reason to learn it?
One thing I did come across was the Javascript issue, whats the best for serving Javascript code in your pages; pretend-XHTML or HTML 4.01 or is it really down to the doctype (strict, transitional)?
And what if you want to feed a flash player or some other script (google map maybe) with a XML file/list, whats the best to use then? or is it the doctype (strict, transitional) issue again?
When served as HTML it must be parsed and interpreted as HTML. If you have a <meta/> tag or a <link/> tag in the document head, you're actually specifying a '>' character, which implies a <body> tag. The documents becomes invalid, but no one will notice since browsers have buggy parsers that let things like this slide.
It does matter. If you use pretend-XHTML you'll have to make sure that it works both when served as HTML and when served as XHTML. There'll be some extra testing required.
ThnaksThe more you learn.... the more you learn there is more to learn.
-
Sep 5, 2008, 05:52 #14
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There are a few who serve XHTML as XHTML, but the vast majority do not. IE's lack of support is, of course, one major reason why real XHTML doesn't stand a chance of becoming mainstream.
Because most people don't understand what XHTML is, but think it's a cooler newer version of HTML.
Well, if you want to apply for one of those jobs, obviously …
The best form is definitely to keep all script code in external files, regardess of HTML/XHTML or Strict/Transitional. For pretend-XHTML it's virtually a requirement, since most non-trivial JavaScript is impossible to write in-document in a way that works both with HTML and XHTML.
Done properly, with object, it can be used in either. Done improperly, with embed, it won't validate against any standard DTD.
I don't quite understand the question here.
Because they don't know about the part where you also have to verify that it works when served as an application of XML. They believe XHTML is a kind of HTML and live happy, carefree lives in blessed ignorance.
Seriously, most people don't know and don't care. That's why I doubt that (real) XHTML will ever supplant HTML.Birnam wood is come to Dunsinane
-
Sep 5, 2008, 06:35 #15
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There are a few who serve XHTML as XHTML, but the vast majority do not. IE's lack of support is, of course, one major reason why real XHTML doesn't stand a chance of becoming mainstream.Because most people don't understand what XHTML is, but think it's a cooler newer version of HTML.sounds good to me, so really it's just something people add to there skill set, make themselves sound a bit more educated, really its useless.. well not really needed.
Well, if you want to apply for one of those jobs, obviously …
The best form is definitely to keep all script code in external files, regardess of HTML/XHTML or Strict/Transitional. For pretend-XHTML it's virtually a requirement, since most non-trivial JavaScript is impossible to write in-document in a way that works both with HTML and XHTML.
Done properly, with object, it can be used in either. Done improperly, with embed, it won't validate against any standard DTD.
I don't quite understand the question here.sorry that will be me having a brain fart...
What I mean is Pretend-XHTML is basically telling all the <meta /> or whatever tag <br /> that they really look like <meta> - content="text/html;
Because they don't know about the part where you also have to verify that it works when served as an application of XML. They believe XHTML is a kind of HTML and live happy, carefree lives in blessed ignorance.
But XML is still very useful for hold large amounts of data in external files? yes? A mean that will never phase out will it?
Seriously, most people don't know and don't care. That's why I doubt that (real) XHTML will ever supplant HTML.
Thanks agianThe more you learn.... the more you learn there is more to learn.
-
Sep 5, 2008, 07:05 #16
I still don't understand why sitepoint, microsoft, and w3c still choose to use an xhtml dtd on their sites instead of html4strict.
-
Sep 5, 2008, 09:46 #17
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Good question. Why do they?
The more you learn.... the more you learn there is more to learn.
-
Sep 5, 2008, 11:26 #18
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It can be because they've bought into the hype, or because they're using a content management system that insists on spitting out XHTML.
Birnam wood is come to Dunsinane
-
Sep 5, 2008, 11:51 #19
- Join Date
- Dec 2005
- Posts
- 1,738
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Again good information Cuckoo thanks
Any comments on my last post #15
And just wondering why do you use XHTML on your blog?The more you learn.... the more you learn there is more to learn.
-
Sep 5, 2008, 13:32 #20
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Some are probably clueless, others think it's a newer HTML. I doubt that many commercial entities dare ignore IE.
Pretend-XHTML is HTML from a browser's point of view, so the answer is no. You can't do anything more with JavaScript in real XHTML, either. Both XHTML and HTML are parsed by the browser to construct a DOM tree. JavaScript can manipulate this DOM tree in clever ways.
It's not that easy, I'm afraid. There's a very common browser that has inadequate support for OBJECT. Guess which one?
Pretend-XHTML 'works' because of parser bugs in all major browsers. <br/> should really be the same as <br>> (i.e., <br>>) when parsed with HTML rules.
If you have a <meta/> tag it should be parsed as a <meta> tag followed by a greater-than character. That character should be takes as the first character of the document content. It should imply a </head> tag and a <body> tag and the '>' should be rendered. Any subsequent meta tags, link tags or style tags should be ignored.
XML is well suited for data storage and information transfer between applications. That is unlikely to change in the foreseeable future.
No good reason, really. I was playing around with content negotiation, and I guess I hadn't quite realised back then how useless XHTML was. I serve XHTML to user agents that claim to prefer it, and HTML (not pretend-XHTML) to the rest. That causes some problems in Safari, which claims to handle XHTML although it doesn't quite make it. (It has some bugs with style sheets declared in PIs.)
If I ever have time to rewrite my blog application I'll go with HTML 4.01 for everyone.Birnam wood is come to Dunsinane
-
Sep 6, 2008, 03:07 #21
- Join Date
- Dec 2004
- Location
- Sweden
- Posts
- 2,670
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Sep 6, 2008, 12:48 #22
- Join Date
- Nov 2004
- Location
- Ankh-Morpork
- Posts
- 12,158
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, that's theoretically correct since Strict DTDs don't allow inline-level content as immediate children of body. And error handling is undefined in HTML4.
In reality, browsers don't seem to parse Strict and Transitional differently. They'll honour <font> tags and <center> tags even with a Strict doctype declaration, for instance.Birnam wood is come to Dunsinane
Bookmarks