SitePoint Sponsor

User Tag List

Results 1 to 22 of 22
  1. #1
    SitePoint Wizard silver trophy
    beley's Avatar
    Join Date
    May 2001
    Location
    LaGrange, Georgia
    Posts
    6,117
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Should we use XHTML even if we don't need any features of XML?

    I've read *most* of the huge thread (argument) on XHTML 1.0 vs HTML 4.01.

    Is there a compelling reason to use XHTML instead of HTML 4.01 Strict in new sites that are not using any features of XML? It's clear that as they're sent as text/html anyway, even the XHTML wouldn't be able to use any of the new features anyway.

    I don't want to duplicate that thread... or get any arguments started. I just want a compelling reason to go through the trouble w/ CSS and scripts for XHTML to work.

    If there's not a great reason, I'm sticking to 4.01 strict.

    Thanks!

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well actually you have posed TWO questions there. No Im NOT going to start the war but here's the part of your post I found interesting (and compelled me to answer)

    I just want a compelling reason to go through the trouble w/ CSS and scripts for XHTML to work.
    The XHTML part is pretty irrelivent and is the BIG argument here BUT the CSS part is almost a given. If you are NOT using CSS for your formatting (please tell me youre not using font tags ... PLEASE) then you are loading your pages with code that is NOTHING but bloat!

    I couldnt for ONE SECOND think of one good reason NOT to use CSS for formatting your pages ... not one.

    Now if you mean the old "css vs tables" .... well then see one of the many many wars that have been posted before.

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If you use your XHTML as input for further processing with XML tools, then keep using XHTML. Otherwise, if XHTML is your final output, there's not much difference at this point between XHTML and HTML 4.

    Why do I make this distinction? XHTML still has XML syntax even if served as text/html, so you can use XML processing tools on it. XML parsers are far more abundant and usually more lightweight than SGML parsers (which you'd need to process HTML) in programming environments, and they usually follow a standard methodology (DOM or SAX parsing), making it easy to get going quickly.

    Edit:

    DC is also right about the CSS part, keep with it. CSS works just as well with HTML 4.01 as it does with XHTML

  4. #4
    SitePoint Wizard silver trophy
    beley's Avatar
    Join Date
    May 2001
    Location
    LaGrange, Georgia
    Posts
    6,117
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    dc dalton - I did not mean to pose a question about CSS at all. That's not even the topic... I was talking about the fact that you have to comment out CSS and scripts in XHTML. I know the importance of using CSS for design and formatting.

    So what's with the commenting of scripts Vinnie? I thought in XHTML you had to use mad comments with javascript or css?

  5. #5
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Scripts and CSS should be external for caching/bandwidth/etc. reasons anyway, but yeah I think you're supposed to define JS/CSS as CDATA in order for it to validate. Not 100% sure.

    XHTML gives you forward compatibility. That's about it. If you ever need to use XML features on it (DOM, XSLT, etc.) you can.

    The way I look at it: Why not? XHTML 1.1 validity is pretty easy to accomplish, you may as well use it.

    (By the way, I haven't t read the other topic (those debates get tiresome), so I apologize if I've just regurgitated the points that were said in the other thread.)

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by beley
    So what's with the commenting of scripts Vinnie? I thought in XHTML you had to use mad comments with javascript or css?
    Scripts just have to be wrapped in CDATA sections instead of comments to be "correct" in XHTML, and this is really only required if your script/css would otherwise invalidate your markup. Example:
    HTML Code:
    <script type="text/javascript">
    //wouldn't validate because of the unencoded ampersands unless
    //you wrap it in a CDATA section
    var isDOM = document.getElementById && document.createComment;
    </script>
    <style type="text/css" media="screen">
    /*just fine without any SGML comments or CDATA*/
    h1 {
      font-size: 25px;
    }
    </style>
    Now, this might not play nice with older browsers (that's why scripts were commented out in the old days), but if you're going XHTML it's an acceptable assumption that the older browsers don't matter as much .

    Of course the easiest thing to do is put these in external files so you never have to worry about the correct way to hide it from browsers .

  7. #7
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry if I missunderstood your question but it seemed like you were asking about both CSS and xhtml!

    To be very honest I dont use js or css in any of my pages (embedded that is) ... I use everything in external files. Do I do xhtml? Yes I do as of last fall ... but again I will do anything possible to keep styles, flash, scripts out of my main documents anyways (html OR xhtml) and seeing as how I do everything dynamically if ones like that so are all the rest.

    Why do I use xhtml? ... well Im TRYING to think as forward as is humanly possible. More or less Im trying to live by my motto of "not paying for the same real estate twice". Its a pain IE doesnt support serving it up as XML so for now, yes, I serve it as html.... but again Im looking forward (we can hope for IE 7)..

  8. #8
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    UK
    Posts
    201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the most pertinent statement so far is "Im TRYING to think as forward as is humanly possible" -- DC Dalton.

    The majority of the work I produce is intranet/extranet based, very little of it is meant for the wider internet audience. I have to work within the contraints of the custom coded 'portal' system that my employers have settled on (well for this week, I'm quite sure that will change next week ... dont you just love government bodies).

    What xhtml does offer me over html 4.x is another degree of separation. js, css , actionscript and the xml are all separate to my xhtml document, it allows me flexability to work and reuse my work without having to rewrite everything because my TD's wife read about a new technology on the BBC.

    When it comes to private work, why not offer your client that flexibility? ...

  9. #9
    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 vgarcia
    Scripts just have to be wrapped in CDATA sections instead of comments to be "correct" in XHTML, and this is really only required if your script/css would otherwise invalidate your markup.
    Using a CDATA section could be a convenient alternative to encoding every '<' and '&#38;' character in the script as &#38;lt; and &#38;amp;. You don't have to use CDATA sections; you just have to make sure that the CSS/script code doesn't cause any well-formedness errors. I know that's what you said, Vinnie, I just wanted to clarify since some beginners seem to believe that the CDATA markup is required (just as they believe the comments are required with HTML).

    Quote Originally Posted by Wythrol
    What xhtml does offer me over html 4.x is another degree of separation. js, css , actionscript and the xml are all separate to my xhtml document
    I'd be very interested in seeing how that is possible. Have you discovered some secret elements or attributes in XHTML that enables better separation than in HTML 4.01? Seeing as XHTML 1.0 is nothing but a reformulation of HTML 4.01 as an application of XML, I find it quite difficult to see how it would offer any extra 'degree of separation.' Could you elaborate on this?
    Birnam wood is come to Dunsinane

  10. #10
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    Using a CDATA section could be a convenient alternative to encoding every '<' and '&' character in the script as &lt; and &amp;. You don't have to use CDATA sections; you just have to make sure that the CSS/script code doesn't cause any well-formedness errors. I know that's what you said, Vinnie, I just wanted to clarify since some beginners seem to believe that the CDATA markup is required (just as they believe the comments are required with HTML).
    Repetition aids in understanding, so no worries

  11. #11
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beley
    Is there a compelling reason to use XHTML instead of HTML 4.01 Strict in new sites that are not using any features of XML? It's clear that as they're sent as text/html anyway, even the XHTML wouldn't be able to use any of the new features anyway.
    It depends on your definition of 'compelling'

    I would say one advantage is that the transition to future versions of XHTML may be easier. Another one is that you may be in a better position to transform your markup into other formats in the future.

    But neither of those examples I gave are of immediate importance.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  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 mmj
    I would say one advantage is that the transition to future versions of XHTML may be easier.
    Oh, definitely. This HTML 4.01:
    HTML Code:
    <h3>Heading</h3>
    <p>Paragraph.</p>
    is so much more work than the corresponding XHTML 1.0:
    HTML Code:
    <h3>Heading</h3>
    <p>Paragraph.</p>
    to convert into XHTML 2.0:
    HTML Code:
    <section>
      <h>Heading</h>
      <p>Paragraph.</p>
    </section>


    Quote Originally Posted by mmj
    Another one is that you may be in a better position to transform your markup into other formats in the future.
    This is true. XHTML is XML, so you can use XSLT to transform the DOM tree into another DOM tree. That is not possible with generic HTML, since it's not well-formed in the XML sense.

    On the other hand, it would probably be better to store the information as XML (not XHTML), and use XSLT to transform it into HTML or XHTML for presentation and to any other XML-based format for other needs.
    Birnam wood is come to Dunsinane

  13. #13
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    Oh, definitely. This HTML 4.01:
    HTML Code:
    <h3>Heading</h3>
    <p>Paragraph.</p>
    is so much more work than the corresponding XHTML 1.0:
    HTML Code:
    <h3>Heading</h3>
    <p>Paragraph.</p>
    to convert into XHTML 2.0:
    HTML Code:
    <section>
      <h>Heading</h>
      <p>Paragraph.</p>
    </section>
    Thing is, most sites marked up with html 4.01 aren't as clean as that. More likely they'll have unclosed paragraphs and certainly images, metas and <link>s - closing empty tags is invalid in html 4.01, so if your markup is standards compliant then you will have a bigger job to port it to xhtml 2.0. Then there's the likelihood of finding presentational markup within html 4.01 based sites - <i><u><b><font> etc will all have to be stripped out.

  14. #14
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by hurricane.uk
    Thing is, most sites marked up with html 4.01 aren't as clean as that. More likely they'll have unclosed paragraphs and certainly images, metas and <link>s - closing empty tags is invalid in html 4.01, so if your markup is standards compliant then you will have a bigger job to port it to xhtml 2.0.
    Yeah, but you can keep an XML/XHTML version of your site offline and use XSLT to transform it into HTML 4.01 easily if you really want your site to be HTML 4.01.
    Quote Originally Posted by hurricane.uk
    Then there's the likelihood of finding presentational markup within html 4.01 based sites - <i><u><b><font> etc will all have to be stripped out.
    Why is it more likely? Those elements are also available in XHTML (and yes I've seen them used on XHTML pages), so I don't follow the logic completely here.

  15. #15
    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 hurricane.uk
    Thing is, most sites marked up with html 4.01 aren't as clean as that.
    Neither are most sites that boast an XHTML doctype.

    I'm not anti-XHTML in any way, but I don't like it when people try to insinuate that documents with an XHTML doctype declaration are automatically clean and valid and semantic, while an HTML doctype automatically means tag soup.

    That's why I'm playing devil's advocate sometimes.
    Birnam wood is come to Dunsinane

  16. #16
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    Why is it more likely? Those elements are also available in XHTML (and yes I've seen them used on XHTML pages), so I don't follow the logic completely here.
    Because those people who've taken the time to convert to xhtml are also more likely to have taken the time to eliminate presentational markup.

  17. #17
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo
    Neither are most sites that boast an XHTML doctype.

    I'm not anti-XHTML in any way, but I don't like it when people try to insinuate that documents with an XHTML doctype declaration are automatically clean and valid and semantic, while an HTML doctype automatically means tag soup.
    If a site is marked up with an xhtml doctype, but the rest of the markup isn't xhtml then it's not xhtml iyswim.

    Take 2 valid sites - one done with valid xhtml and one in valid html then the one in html will have to go back and close all the tags. That's the point I was making.

  18. #18
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by hurricane.uk
    Because those people who've taken the time to convert to xhtml are also more likely to have taken the time to eliminate presentational markup.
    You'd think so, except Dreamweaver makes "XHTML" really easy with a simple checkbox. Then you can add any presentational markup your heart desires because Dreamweaver will automatically add the trailing slash to any elements that need them!

    It's not always clear cut. XHTML does not mean good markup. HTML 4 does not mean bad markup.

  19. #19
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vgarcia
    You'd think so, except Dreamweaver makes "XHTML" really easy with a simple checkbox. Then you can add any presentational markup your heart desires because Dreamweaver will automatically add the trailing slash to any elements that need them!

    It's not always clear cut. XHTML does not mean good markup. HTML 4 does not mean bad markup.
    Push of a button conversion isn't really taking the time

    http://www.w3.org/MarkUp/#guidelines
    FONT tag considered harmful! Many filters from word-processing packages, and also some HTML authoring tools, generate HTML code which is completely contrary to the design goals of the language. What they do is to look at a document almost purely from the point of view of layout, and then mimic that layout in HTML by doing tricks with FONT, BR and &nbsp; (non-breaking spaces). HTML documents are supposed to be structured around items such as paragraphs, headings and lists. Yet some of these documents barely have a paragraph tag in sight!

    The problem comes when the content of pages needs to be updated, or given a new layout, or re-cast in XML (which is now to be the new mark-up language). With proper use of HTML, such operations are not difficult, but with a muddle of non-structural tags it's quite a different matter; maintenance tasks become impractical. To correct pages suffering from injudicious use of FONT, try the HTML Tidy program, which will do its best to put things right and generate better and more manageable HTML.
    I thought that dreamweaver used a version of the W3C's htmltidy? If so then I would have thought that it'd strip presentational markup out and replace it with header embedded CSS.

  20. #20
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by hurricane.uk
    Take 2 valid sites - one done with valid xhtml and one in valid html then the one in html will have to go back and close all the tags. That's the point I was making.
    Regular expressions or htmltidy -- it's not very hard to add the slashes.

    Quote Originally Posted by hurricane.uk
    Because those people who've taken the time to convert to xhtml are also more likely to have taken the time to eliminate presentational markup.
    Well, in theory without taking into the account that people are lazy, yes, but in practice many people do not bother to do the proper research before jumping on
    the bandwagon of a new technology.

    Quote Originally Posted by hurricane.uk
    I thought that dreamweaver used a version of the W3C's htmltidy? If so then I would have thought that it'd strip presentational markup out and replace it with header embedded CSS.
    Do you have any idea how hard it would be to write a program to do that?
    Programming a good WYSIWYG X/HTML editor is extremely difficult, which is why they are all junk.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  21. #21
    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 hurricane.uk
    Take 2 valid sites - one done with valid xhtml and one in valid html then the one in html will have to go back and close all the tags. That's the point I was making.
    All the tags? There are only a few elements where you can omit the end-tag in HTML, and most of them can only occur in the HEAD. Most of the rest are presentational and should be avoided anyway.

    OK, if it's a photo gallery, there may be a few IMG element where you need to add a slash, but that's a few seconds' worth with a regular expression.
    Birnam wood is come to Dunsinane

  22. #22
    SitePoint Addict hurricane.uk's Avatar
    Join Date
    May 2003
    Location
    Liverpool
    Posts
    361
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    2 answers in one

    HTML Kit's version of html tidy strips presentational markup out and replaces it with header embedded css.

    By all - I mean every instance of them, along with closing the empty ones.


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
  •