HTML comments
writing notes while structuring webpages
// updated 2025-04-30 11:10
HTML comments allow us to enter notes in an HTML file without directly affecting what displays on a page:
1<html>
2
3 <head>
4
5 ...
6
7 </head>
8
9 <body>
10
11 <!-- this is a comment -->
12 <!-- here is another comment -->
13 <!-- don't forget to finish this website (you probably won't!) -->
14
15 </body>
16
17</html>
In general:
1<!-- (some one line message) -->
Comments can also have multiple lines:
1<!--
2
3this
4will
5work
6too
7
8-->
DOCTYPE: a special kind of comment
These days, you need only place this at the top of any HTML document or template:
1<!DOCTYPE html>
2<html>
3...
4</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:
1<!DOCTYPE HTML PUBLIC
2"-//W3C//DTD HTML 4.01 Transitional//EN"
3"http://www.w3.org/TR/html4/loose.dtd" >
Some code archives and old, under-maintained websites may still have these "verbose" kinds of DOCTYPES!