473,395 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Comment in XHTML causes error in IE6 display

Hi,

I downloaded a sample form from formsplayer.com, extracted the source
code and made some simple (I thought) mods. I added the comments
before the html tag and the comments on the namespace definitions.

The first two comments provided no problem, but Comment 1 created an
error when I attempted to open this file in IE6 (ver. 6.0.2800.1106)
over Win2000ProSP4: it displayed some trash. When I removed Comment
1, all was well.

Can you tell me precisely why that one comment gave rise to an error?
The code follows.

TIA,
Richard
<!-- HelloWorld.html -->

<!-- Source: http://www.formsplayer.com/... -->

<html
xmlns="http://www.w3.org/1999/xhtml" <!-- Comment 1 -->
xmlns:xf="http://www.w3.org/2002/xforms/cr" <!-- Comment 2 -->

[snip]
Jul 20 '05 #1
2 2744
In article <32**************************@posting.google.com >, Richard wrote:
Can you tell me precisely why that one comment gave rise to an error?
The code follows.
[snip]
<html
xmlns="http://www.w3.org/1999/xhtml" <!-- Comment 1 -->
xmlns:xf="http://www.w3.org/2002/xforms/cr" <!-- Comment 2 -->


Comments can't be placed inside HTML tags. IE probably[1] terminates the
<html> tag at the TAGC delimiter[2] and drops the rest of the intended
contents into the document as text, or something. I'm not quite sure what's
to be achieved by trying to mix XHTML+XForms in IE right now, given that it
only supports XHTML-as-tag-soup, but as you will.

[1] Predicting what a given browser does with invalid HTML is tricky, at
best.

[2] The SGML term for "tag-close", which will be ">" for anything remotely
resembling a practical case.

--
Chris Hoess
Jul 20 '05 #2
RL******@comcast.net (Richard) wrote in message news:<32**************************@posting.google. com>...

From the W3C specs on HTML comments:

"White space is not permitted between the markup declaration open
delimiter("<!") and the comment open delimiter ("--"), but is
permitted between the comment close delimiter ("--") and the markup
declaration close delimiter (">"). A common error is to include a
string of hyphens ("---") within a comment. Authors should avoid
putting two or more adjacent hyphens inside comments."

"Information that appears between comments has no special meaning
(e.g., character references are not interpreted as such)."

"Note that comments are markup."

The first paragraph has a clue: the markup declaration close delimiter
(">").

Also from the W3C specs, this time from the definition of Attributes:

"Attribute/value pairs appear before the final ">" of an element's
start tag. "
<html
xmlns="http://www.w3.org/1999/xhtml" <!-- Comment 1 -->
xmlns:xf="http://www.w3.org/2002/xforms/cr" <!-- Comment 2 -->


When the parser hit the first "-->", it saw the "--" as the end of the
comment and interpreted the ">" as the closing the "html" element.

I see this as being similar to overlapping other tags, like:

<b <em>Hello</em>> there</b>

The browser may not choke, but one thing is for sure: do not count on
predicting the behavior. Put another way, do not put comments inside
of the opening "<" and closing ">" of any element.

By the way, stepping through a debugger and looking at the DOM
representation of your example shows clearly that it closed the HTML
element with the ">" from the first comment. The second xmlns
attribute was not present and the second comment ended up in the
<head>. FWIW

Code Ronin
-- Have Keyboard, Will Travel
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
by: CMAR | last post by:
What are the pluses and minuses of constructing and validating between XHTML Transitional vs. HTLM 4.01 Strict Thanks, CMA
21
by: kaeli | last post by:
Hey all, Does anyone know if all the newer browsers support XHTML? My main target is IE6/NN6+(firefox/mozilla/etc), but I'd like to know if Safari, Opera, Konqueror, and other browsers also...
82
by: Buford Early | last post by:
I read this in http://annevankesteren.nl/2004/12/xhtml-notes "A common misconception is that XHTML 1.1 is the latest version of the XHTML series. And although it was released a bit more than a...
12
by: Alex D. | last post by:
How can I stop asp.net from rendering XHTML istead of HTML? My javascripts are rendering wrong because of that. It is rendering &amp; to clients instead of &. Any help? Thanks, Alejandro.
9
by: anupamjain | last post by:
Hi, After 2 weeks of search/hit-and-trial I finally thought to revert to the group to find solution to my problem.(something I should have done much earlier) This is the deal : On a JSP...
19
by: Bert Lancaster | last post by:
I'm not actually using it on the web but can anyone tell me why the ID attribute on a <style> tag causes an error in the W3C validator for an XHTML 1.1 document? It doesn't have a problem for a...
22
by: Ted | last post by:
This page http://homepage.ntlworld.com/r.a.mccartney/test/utf-8_test_file_hacked_for_ie_with_local_dtd.xml doesn't work properly in Firefox or IE6. The faults are different. In Firefox the...
2
by: mszanto | last post by:
I've read a bunch of posts on this and none of the answers are legitimate (IMHO) so I thought I'd throw it out there again. Using the html code below, if you set the doctype to HTML 4.0, and...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.