SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: XHTML and DOM

  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XHTML and DOM

    I've been working with XHTML 1.0 Transitional for a while, but lately I've decided to completely convert to XHTML 1.0 Strict so I can be more accustomed to the correct standards. But as I work I see that more and more websites are converting to XHTML 1.1. Soon I start looking into the differences for XHTML 1.1, and even now I'm still not sure about what the exact differences are (this includes after reading a lot of articles and topics including the stickied thread in this forum). From what I've read, I vaguely understand that XHTML 1.1 has these features:
    • Expands from XHTML 1.0 Strict (which is sort of an oxymoron since it seems to take away a lot of tags and attributes)
    • Works as a module
    • Releases something called XHTML Basic

    I don't get why someone would even use XHTML 1.0 Strict if XHTML 1.1 has been released and even recommended by the W3C, yet XHTML 1.0 is still recommended as well and even the W3C's website uses XHTML 1.0 Strict instead of XHTML 1.1. I'm not quite sure how the word "module" is being defined either. Generally it makes me think of something categorized on its own that can work independently from something else. Does that mean that XHTML 1.0 and 1.1 are somewhat split from each other and it's just a matter of preference to choose which one to use? Also I have no idea what XHTML Basic is. Just by reading all of this text you can tell how confused I am. Can someone just flat out give me a relatively easy to read explanation on the differences between XHTML 1.0 and 1.1 and why I should use one or the other? I feel like I want to stick with XHTML 1.0 Strict, but I just don't know why. I don't want the answer of, "Just go with the latest version because it's the newest" since I've read that a lot in many forums already and that answer is not enough to suffice my question.

    ...Also another short question that's out of the blue. I'm not really sure what the document object model really is. I've also looked into it and failed to really get a clear answer. I understand it's probably annoying to hear these newbie questions like these, but I'd really appreciate it if I could hear a straight on answer since I don't seem to be getting anywhere when I look around the internet.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    XHTML 1.1 has been broken up into a number of modules. You include the modules in your page that are required for the tags that your page uses. Each module puts the tags into its own separate namespace allowing multiple modules to (if necessary) use the same tag for different purposes. This allows proper eXtensibility of the language (what the X on the front of XHTML represents) way beyond that possible in version 1.0 (which was merely a reworking of HTML to use as a starting point for the new markup language.

    Web sites are unlikely to be converting to XHTML 1.1 since it is not usable for creating web pages since the most popular web browser (Internet Explorer) does not support XHTML at all. Any XHTML page just gets offered for download if you access it with that browser. While you can use the subset of XHTML 1.0 that corresponds to HTML 4, serve it as HTML and have the browsers treat it as slightly invalid HTML 4, the same is not possible with XHTML 1.1 which will only work if actually served properly as XHTML.

    The Document Object Model is a representation of all of the elements in the web page as an upside down tree structure which programming languages can use to interact with the page content. For example JavaScript can access the XHTML element having a particular id which is in a given namespace using document.getElementByIdNS(id,ns) where id is a variable containing the id of the element you want to access and ns is a variable identifying the XHTML namespace to look for it in.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    I know that it's exciting to work with XHTML 1.0 and XHTML 1.1 but because of the IE issue, all work has to be dumbed down and made compatible so that HTML only browsers are capable of understanding it.

    Given those limitations, there is no real incentive to code in XHTML, because the realizable benefits of doing just aren't there.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XHTML 1.0 is a reformulation of HTML 4.01 as an application of XML 1.0.
    XHTML 1.1 is a reformulation of XHTML 1.0 Strict using Modularization of XHTML.

    The XHTML 1.0 document type definition (DTD) was split into a number of modules (and the one for Ruby annotations was added). The intention was that you could combine precisely the modules you need for a document. XHTML Basic is the minimum set of modules needed for general-purpose use. XHTML 1.1 is what you get when you put all of the modules back together.

    XHTML 1.1 is not backward compatible with HTML, so it mustn't be served as text/html. That means it won't work in any version of Internet Explorer. In other words, it's absolutely useless for public websites.

    My advice is to forget you ever heard of XHTML 1.1. (The best thing would be to forget XHTML altogether, since HTML 4.01 is the latest usable specification.)

    The document object model is the internal representation of an SGML or XML document. It consists of a hierarchy of 'nodes', with a single 'root node'. Each (X)HTML element is represented by an Element node. Text content is represented by Text nodes (or CDATASection nodes).

    The DOM is accessible via JavaScript, so you can manipulate it. You can add, remove and replace nodes after the document has loaded.
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Addict mason.sklut's Avatar
    Join Date
    Oct 2006
    Posts
    200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. I personally see a lot of sites still using XHTML 1.0 Transitional....
    Go ahead and use XHTML 1.0 Strict if you like -- it has to be really valid code

    2. DOM -- this site may explain something of use: http://urli.ca/mu

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,564
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    I really only see idiot programmers use transitional. Either that or they are just plain lazy. Transitional isn't supposed to be permanent. Those who keep it are ignorant or lazy.

    IMO.
    Twitter-@Ryan_Reese09
    http://www.ryanreese.us -Always looking for web design/development work

  7. #7
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,786
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Any new web sites should be developed using a strict doctype. The transitional doctypes are intended for existing sites that have old code in the pages that you have not yet had time to correct. Starting with a transitional doctype just means you are creating broken pages in the first place and will need to go back and fix them later rather than creating them properly in the first place.

    The only reason for creating new pages using a transitional doctype is if your pages all use a template and that template still uses deprecated code that you haven't replaced with the correct code yet. You certainly shouldn't be using any deprecated tags and attributes in any new code that you write and so all the new content at least should validate as strict.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  8. #8
    SitePoint Wizard silver trophybronze trophy
    Join Date
    Jul 2008
    Location
    New York, NY
    Posts
    1,432
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Any new web sites should be developed using a strict doctype. The transitional doctypes are intended for existing sites that have old code in the pages that you have not yet had time to correct. Starting with a transitional doctype just means you are creating broken pages in the first place and will need to go back and fix them later rather than creating them properly in the first place.

    The only reason for creating new pages using a transitional doctype is if your pages all use a template and that template still uses deprecated code that you haven't replaced with the correct code yet. You certainly shouldn't be using any deprecated tags and attributes in any new code that you write and so all the new content at least should validate as strict.
    Correct, Most coders seem to misinterpret the real meaning of a transitional Doctype.

  9. #9
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,683
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    For me the mindset of using transitional, or at least it was a long time ago when I was using it, is that you want your pages to still validate correctly while at the same time you are learning about the next markup language. It should only stay as transitional while you learn about the new one and how to get the old deprecated code working in the new code.

    I'm not that comfortable with there being a transitional doctype in the first place, and if it weren't for the above scenario, there would be a strong argument against its requirement in the first place.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #10
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should never create a new document with a Transitional doctype declaration. It's intended for the process when you want to modernise an old document which probably won't have a doctype declaration at all. You then put in Transitional declaration so that you can validate the markup and make sure it's syntactically correct. After that you start removing deprecated tags and attributes, replacing them with CSS and unobtrusive JavaScript, until your document is not only syntactically correct but also semantically correct. Finally, you replace the Transitional declaration with a Strict one and validate again to make sure you got it all right.
    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
  •