IgorShare Thoughts and Ideas

Consulting and Training

Am I the only one? or Html is not that XML compliant.

Posted by Igor Moochnick on 12/18/2008

While working on my latest project, I’ve noticed that my site (that uses jQuery) was working properly on Google Chrome, but wasn’t working at all (without any errors) on IE7 and FF.

After very long fight I’ve noticed that (are you ready for this?) it does matter how you close the <script> tag.

Compare this (WORKING !!!):

<script src="scripts/jquery-1.2.6.js" type="text/javascript"></script>

with this (NOT WORKING !!!):

<script src="scripts/jquery-1.2.6.js" type="text/javascript" />

Note that the closing tag HAVE to be present as a separate node. YOU CAN’T USE THE SHORT NOTATION !!!

Advertisements

6 Responses to “Am I the only one? or Html is not that XML compliant.”

  1. HUjuice said

    You’re not the only one!
    And it’s a mystery for me too…

    But I think that it’s not an (X)HTML/XML problem, but a JavaScript issue.

    If you try the three files at http://inservibile.org/xhtml/, you see that the short one is W3C valid (http://validator.w3.org/check?uri=http://inservibile.org/xhtml/short.html) and that JS has some effect: it make the whole body disappear!
    Inspecting the page with FireBug, the result is a content part…
    It happens even if you omit the “onload” event.

    So, the document object has been altered using the short notation. I don’t know why…

    I hope that my poor english language would be comfortable.

    Regards,
    HUjuice

  2. HUjuice said

    grrr, I wrote
    “the result is a «body /» content part…”, with the obvious notation… 🙂

  3. boroscope said

    those types of bugs can just suck up your time! very annoying when you’re sure it should be working

    • Exactly. I’ve lost about an hour while I’ve figured out why my style sheets were not loading 😦 – those are the dangers of writing the HTML manually

  4. HTML and XML are different languages. XHTML is an interesting blend that can be interpreted by both HTML parsers and XML parsers. So HTML is definatly not XML compliant, but XHTML is. Does FF and IE7 parse XHTML properly? Not sure, but what often happens is that as soon as a browser sees HTML (even XHTML) it does a loose parsing using HTML (versus the strict XML parsing). This is probably why HTML 5 will succeed even though W3C has been pushing XHTML to replace HTML.

    But the empty tag syntax gets me all the time in other places. I wasted almost a day dealing with a stupid CAML query (SharePoint’s query language) when I found out that their XML parser didn’t like the empty tag syntax either! Part of the problem is that parsers treat empty tags in the form of <ELEMENT></ELEMENT> differently than <ELEMENT/>. Pain! According to the XML spec these are supposed to be the same!

  5. Yes, it’s not working. I had the same problem few days ago. Keep using :

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: