HTML and CSS Reference
In-Depth Information
HTML Comments
A comment is a piece of code that is fully ignored by any web browser. The reason for its
existence is to either provide information about the code or to remove sections of the code
but leave them available for later use. Comments can even act as notifications and reminders
in your HTML. In alignment with good practice, we add comments into our HTML code,
especially in complex documents, to indicate sections of a document. This will help us and
others to better understand the code and increase its readability.
We can create an HTML comment using the character sequence <!-- to mark the start of the
comment, and the character sequence --> to mark the end of the comment. When parsing the
document, the web browser will automatically ignore everything placed between these two
markers, regardless of whether it is plain content or HTML markup. The following example
puts an HTML comment before the Education section.
<hr>
<!-- Starting Education section-->
<h2>Education</h2>
We can place our comments in multiple lines as long as <!-- is placed before the first line
and --> is placed after the last line. However, the double-dash sequence "--" may not appear
inside a comment except as part of the closing --> tag. This prevents comment nesting, as a
comment cannot be nested inside another comment without the double-dash. Additionally,
we must make sure that there are no spaces in the start-of-comment string between '<' and
'!', meaning that < !-- will not be rendered properly. For example, if we comment out the list
in the Portfolio section in the final document, the browser will only display the paragraph
text.
<h2 id="portfolio">Portfolio</h2>
<p>I have worked as a freelance web designer for the following companies</p>
<!--
<ul>
 
Search WWH ::




Custom Search