HTML comments
writing notes while structuring webpages
// updated 2025-04-22 15:29
HTML comments allow us to enter notes in an HTML file without directly affecting what displays on a page:
<html>
<head>
...
</head>
<body>
<!-- this is a comment -->
<!-- here is another comment -->
<!-- don't forget to finish this website (you probably won't!) -->
</body>
</html>
In general:
<!-- (some one line message) -->
Comments can also have multiple lines:
<!--
this
will
work
too
-->
DOCTYPE: a special kind of comment
These days, you need only place this at the top of any HTML document or template:
<!DOCTYPE html>
<html>
...
</html>
This page will let the browser know that your HTML file uses HTML 5!
Note that although the doctype looks like a comment, it differs in that it begins with only <!
rather than <!--
Doctypes used to look more complex, e.g. in HTML 4.01:
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >
Some code archives and old, under-maintained websites may still have these "verbose" kinds of DOCTYPES!
This page is part of the HTML textbook!