<!--Why do I have to be Mr Pink?-->
The example above shows a comment with the value Why do I have to
be Mr Pink?
Why do I have to
be Mr Pink?
Comment interface inherits from CharacterData, and represents the contents of an
XML or HTML comment (ie. everything between, but not including, the
starting <!-- and ending -->)
A Comment node cannot have children.
Internet Explorer 5.5 in HTML doesn't implement
the Comment interface — it sees comments as Element nodes with the name !;
consequently it doesn't inherit any properties from CharacterData, and inherits from Node as
Internet Explorer 6
and 7 in XML do not inherit the normalize method from Node.
Safari 1.3 and 2 in HTML mode1 don't
implement the Comment interface, and cannot see
comments at all.
All browsers treat
comments that are inside <script> and
<style> elements in HTML mode differently than
comments inside other elements. Internet
Explorer sees them as empty elements (having no child nodes,
although the content can be retrieved using the proprietary
innerHTML and innerText
properties (including the comment markers themselves)).
Firefox, Safari and
Opera treat the contents of these elements as a
single Text node (including the comment markers
themselves, except for Opera with a
<script> element, in which case the starting
<!-- is not included). Although this difference in
behavior is technically a bug, it matches the expectations of legacy
coding practise, in which script and style information was often
surrounded with an HTML comment to prevent older browsers from rendering
XHTML or HTML pages served as text/html.
To post a note on this topic, please log in
with your SitePoint username and password. If you don't have an account yet, you can
create a new account for free.
The contents of this webpage are copyright © 1998-2013 SitePoint Pty. Ltd. All Rights Reserved.
Web Design & Development by SitePoint, Melbourne, Australia – 99designs.com