Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
HTML element
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Comments== {{Clear}} {{glossary}} {{term|term=comment |content= {{code|lang=html|code=<<nowiki />!-- A Comment -->}} }} {{defn|1= <p>A [[Comment (computer programming)|comment]] in HTML (and related XML, SGML and SHTML) uses the same syntax as the [[SGML comment]] or [[XML comment]], depending on the doctype.</p> <p>Unlike most HTML tags, comments do not nest. More generally, there are some strings that are not allowed to appear in the comment text. Those are {{code|lang=html|code=<!<nowiki />--}}(the beginning of a comment),{{code|lang=html|code=-->}}(this ends the comment so it trivially follows it can not appear inside it) and {{code|lang=html|code=--!>}}. Additionally, the strings {{code|lang=html|code=>}} and {{code|lang=html|code=->}} cannot appear at the beginning of a comment and {{code|lang=html|code=<!-}} cannot appear at the end.<ref>{{cite web|url=https://html.spec.whatwg.org/multipage/syntax.html#comments|title=HTML standard|website=html.spec.whatwg.org}}</ref></p> <p>As a result, the markup {{code|lang=html|code=<!<nowiki />--Xbegin<<nowiki />!--Y-->Xend-->}} is ill-formed and will yield the comment {{samp|{{nobr|Xbegin<!--Y}}}} and the text {{samp|{{nobr|Xend-->}}}} after it, or sometimes just {{samp|Xend-->}}, depending on browser.</p> <p>Comments can appear anywhere in a document, as the HTML parser is supposed to ignore them no matter where they appear so long as they are not inside other HTML tag structures (i.e., they cannot be used next to attributes and values; this is invalid markup: <code>{{nobr|1=<span id="x1"}}{{nobr|<!--for}} "extension {{nobr|one"-->}} {{nobr|1=style="...">}}</code>).</p> <p>Comments can even appear before the doctype declaration; no other tags are permitted to do this.</p> <p>However, not all browsers and HTML editors are fully compliant with the HTML syntax framework and may do unpredictable things under some syntax conditions. Defective handling of comments only affects about 5% of all browsers and HTML editors in use, and even then only certain versions are affected by comment mishandling issues (Internet Explorer 6 accounts for most of this high percentage).</p> <p>There are a few compatibility quirks involving comments:</p> * Placing comments β or indeed any characters except for white-space β before the <code>doctype</code> will cause Internet Explorer 6 to use [[quirks mode]] for the HTML page. None of the <code>doctype</code> information will be processed. * For compatibility with some pre-1995 browsers, the contents of {{tag|style|o}} and {{tag|script|o}} elements are still sometimes surrounded by comment delimiters, and CSS- and script-capable browsers are written to specifically ignore that comment markup as not actually a comment. This means that attempts to actually comment out CSS and script markup by change the elements inside the comment to not be recognized, e.g. <code>{{nobr|<--}} {{nobr|[script]...}}[/script] {{nobr|-->}}</code>. * The [[BlueGriffon]] HTML editor, in versions 1.7.{{var|x}}, makes comments that are not embedded in the syntax structure; {{code|lang=html|code=<style> ... {comment tags} ...</style>}} will show up on-screen. Other HTML editors may have this same defect. }} {{glossary end}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)