SitePoint Sponsor

User Tag List

Results 1 to 22 of 22
  1. #1
    SitePoint Wizard
    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" />
    Which gets served up as html (text/html MIME type)

    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">
    just trying to get my head around all this, seems to be alot of views about just using HTML 4.01 instead of XHTML, but if the first example is still serving as HTML whats the benefit?

    Do you just like working with the XHTML syntax, whats your views?

    Or am I missing something?

    Thanks cb
    The more you learn.... the more you learn there is more to learn.

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    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.

  3. #3
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Wizard
    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".
    thanks Dan just followed what w3c tutorials

    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.
    yes and down to that IE just cant handle it? yes

    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.
    yes cyjetsu... thats exactly what I thought, everybody seems to be using it but serving out html
    The more you learn.... the more you learn there is more to learn.

  5. #5
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  6. #6
    SitePoint Wizard
    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.

  7. #7
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    seems to be alot of views about just using HTML 4.01 instead of XHTML, but if the first example is still serving as HTML whats the benefit?
    There is no technical benefit at all.

    Quote Originally Posted by computerbarry View Post
    yes and down to that IE just cant handle it? yes
    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.

    Quote Originally Posted by computerbarry View Post
    So general speaking there is know difference then?
    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.

    Quote Originally Posted by computerbarry View Post
    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?
    Strict is definitely recommendable over Transitional, since it promotes better practices (like separating content and presentation).

    Quote Originally Posted by computerbarry View Post
    And are you saying if I use the second example "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional" use strict here also?
    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

  9. #9
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,738
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Cuckoo

    There is no technical benefit at all.
    so like dan said "Personal preference..."

    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.
    So really people just use it because everybody else is and think its the way forward even though they don't know the benefits/limitations?

    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.
    meaning because pretend-XHTML is serving as HTML its invalid?

    Strict is definitely recommendable over Transitional, since it promotes better practices (like separating content and presentation).
    yes with you on that thanks

    Is that the complete doctype you posted?
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    "Use the complete doctype declaration with a URI at the end, to trigger standards mode in modern browsers."

    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.

    Thanks
    The more you learn.... the more you learn there is more to learn.

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    Use the complete doctype declaration with a URI at the end, to trigger standards mode in modern browsers. If you omit the URI, Opera, Firefox and others will use their almost-standards mode (which is about the same as IE's standards mode).
    No, you still get the full standards mode.
    Simon Pieters

  11. #11
    SitePoint Wizard
    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.

  12. #12
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    so like dan said "Personal preference..."
    Yes.

    Quote Originally Posted by computerbarry View Post
    So really people just use it because everybody else is and think its the way forward even though they don't know the benefits/limitations?
    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.

    Quote Originally Posted by computerbarry View Post
    meaning because pretend-XHTML is serving as HTML its invalid?
    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.

    Quote Originally Posted by computerbarry View Post
    Is that the complete doctype you posted?
    Yes.

    Quote Originally Posted by computerbarry View Post
    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.
    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.

    Quote Originally Posted by zcorpan View Post
    No, you still get the full standards mode.
    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

  13. #13
    SitePoint Wizard
    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.
    So generally speaking nobody is serving xhtml at all, it's just pretend-xhtml, and if it was real xhtml IE would just crumple anyway.

    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.
    So would that just act like some sort of converter, basically covert the XHTML to HTML so we can read it?

    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.
    I'm starting to think why people even use pretend-XHTML at all, doing the same job but just creating more work for yourself (like you said more checking)?

    Thnaks
    The more you learn.... the more you learn there is more to learn.

  14. #14
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    So generally speaking nobody is serving xhtml at all, it's just pretend-xhtml, and if it was real xhtml IE would just crumple anyway.
    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.

    Quote Originally Posted by computerbarry View Post
    If thats the case why is there so many jobs/job spec asking for XHTML?
    Because most people don't understand what XHTML is, but think it's a cooler newer version of HTML.

    Quote Originally Posted by computerbarry View Post
    Is there any real reason to learn it?
    Well, if you want to apply for one of those jobs, obviously …

    Quote Originally Posted by computerbarry View Post
    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)?
    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.

    Quote Originally Posted by computerbarry View Post
    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?
    Done properly, with object, it can be used in either. Done improperly, with embed, it won't validate against any standard DTD.

    Quote Originally Posted by computerbarry View Post
    So would that just act like some sort of converter, basically covert the XHTML to HTML so we can read it?
    I don't quite understand the question here.

    Quote Originally Posted by computerbarry View Post
    I'm starting to think why people even use pretend-XHTML at all, doing the same job but just creating more work for yourself (like you said more checking)?
    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

  15. #15
    SitePoint Wizard
    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 …
    well if all this is right, the companies must either be clueless themselves or they don't worry about the IE issue...? or again they just think it's the latests/better version of HTML.

    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.
    Yes I understand the external issue, what I mean is can more be done with pretend-XHTML than HTML regarding using the latest javascript functions?

    Done properly, with object, it can be used in either. Done improperly, with embed, it won't validate against any standard DTD.
    I had a little problem myself with the EMBED... so replace all EMBED tags with OBJECT?

    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.
    it's a funny old world isn't it.

    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.
    I don't see how it can if IE stays around and I think that will be a very long time

    Thanks agian
    The more you learn.... the more you learn there is more to learn.

  16. #16
    SitePoint Guru cyjetsu's Avatar
    Join Date
    May 2008
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still don't understand why sitepoint, microsoft, and w3c still choose to use an xhtml dtd on their sites instead of html4strict.

  17. #17
    SitePoint Wizard
    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.

  18. #18
    SitePoint Author silver trophybronze trophy

    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

  19. #19
    SitePoint Wizard
    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.

  20. #20
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    well if all this is right, the companies must either be clueless themselves or they don't worry about the IE issue...? or again they just think it's the latests/better version of HTML.
    Some are probably clueless, others think it's a newer HTML. I doubt that many commercial entities dare ignore IE.

    Quote Originally Posted by computerbarry View Post
    Yes I understand the external issue, what I mean is can more be done with pretend-XHTML than HTML regarding using the latest javascript functions?
    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.

    Quote Originally Posted by computerbarry View Post
    I had a little problem myself with the EMBED... so replace all EMBED tags with OBJECT?
    It's not that easy, I'm afraid. There's a very common browser that has inadequate support for OBJECT. Guess which one?

    Quote Originally Posted by computerbarry View Post
    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;
    Pretend-XHTML 'works' because of parser bugs in all major browsers. <br/> should really be the same as <br>> (i.e., <br>&gt;) 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.

    Quote Originally Posted by computerbarry View Post
    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?
    XML is well suited for data storage and information transfer between applications. That is unlikely to change in the foreseeable future.

    Quote Originally Posted by computerbarry View Post
    And just wondering why do you use XHTML on your blog?
    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

  21. #21
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    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.
    For Transitional, yes, but for Strict it would be invalid and hence parsing rules undefined.
    Quote Originally Posted by AutisticCuckoo View Post
    Any subsequent meta tags, link tags or style tags should be ignored.
    No, it's undefined.

    But this is just nitpicking on a theoretical issue.
    Simon Pieters

  22. #22
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zcorpan View Post
    For Transitional, yes, but for Strict it would be invalid and hence parsing rules undefined.
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •