HTML 5 & java script (using simply JS book)

hi,
I`m trying to learn java script with the Simply java script book but i want to implement it on HTML5 web sites.

  1. is the DOM different in HTML5? like I want to use the getElementsByTagName method, is it different when using an html5 page?

  2. are there other differences between programming Java Script for HTML5 them for XHTML??? and if so how do I overcome those differences.

thank u for helping.

HTML 5 is still in draft and is basically HTML 4 with lots of extra tags and attributes added (many of which are completely unnecessary and ought to be removed before it gets much further along the development process). Also since HTML 5 just uses the short version of the HTML 2 doctype there is no way of specifically identifying HTML 5. You can access it via the HTML DOM just the same as for any other version of HTML.

There are significant differences between using JavaScript with HTML and using it with XHTML as XHTML has its own separate DOM. With XHTML you would use getElementsByTagNameNS in order to specify an additional parameter that defines which namespace that you want to get the tags from.

I’m not really getting what ur saying, I learned HTML5 and now I’m studying java script and I want to use it on my HTML5 built site, is there a different Java script syntax that I should use than the one I would use on XHTML??
Do you have a reference to a site or article that would help me?

Thanks alot…

With HTML whether it is HTML2 or HTML 5 or anything in between you would use JavaScript with the HTML DOM. The HTML DOM contains commands such as getElementsByTagName(‘p’)

With XHTML whether XHTML 1.0 or XHTML 5 you would use JavaScript with the XHTML DOM. It contains commands such as getElementsByTagNameNS(“http://www.w3.org/1999/xhtml”, “p”)

In both of those the call is retrieving all of the paragraph tags but in the case of the XHTML one it is specifying that only those that are a part of XHTML namespace re to be retrieved and that any “p” tags that exist in any other namespace within the document should be ignored as they are not paragraphs.

The whole purpose of XHTML is that it is defined as XML and so you can incorporate any other XML based document type into the same document simply by listing all the namespaces in the xmlns attribute of the html tag - so JavaScript needs to specify which of those namespaces it is processing with a given call.