HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 2. CONTENT VS MARKUP 22


2.2.7 Comments


It is sometimes handy to put notes into a webpage, notes that are intended
for future authors (including yourself) to explain this or that. These notes
are not intended to be rendered as part of the webpage seen by your ultimate
readers. They are for the authors.


are used to surround an HTMLcomment.

Those tags and everything between them will not be rendered (displayed)
by the browser.


Comments cannot be nested. When a comment starts, it continues until the
first end tag is found. Here is an example of what I mean.


Here is a comment.


aaa eee


Here is another comment.



If we insert the second comment into the middle of the first one, we get this:


aaa <!-- bbb ddd --> eee


In this example, the comment that will be recognized by the browser is


because the first-->marks its end. After the

comment is ignored, this is what will be rendered.


aaa ddd --> eee


Oops.


Exam Question 23(p.337): What character sequence marks the start of
a comment in HTML?
Required Answer:<!--


Exam Question 24(p.337): What character sequence marks the end of a
comment in HTML?
Required Answer:-->


Exam Question 25(p.337):What character sequence is not allowed within
a comment in HTML5?
Required Answer:--


Exam Question 26(p.338):In HTML, can comments be nested?
Required Answer:no

Free download pdf