Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

HTML Comments

Comments in HTML pages are placed between <!-- and --> tags (use at least two hyphens, although more are allowed). Being able to locate all comments is useful when browsing (and debugging) Web pages.

<!-- Start of page -->
<HTML>
<!-- Start of head -->
<HEAD>
<TITLE>My Title</TITLE> <!-- Page title -->
</HEAD>
<!-- Body -->
<BODY>
<!-{ 2,} .*?-{ 2,} >
<!-- Start of page -->
<HTML>
<!-- Start of head -->
<HEAD>
<TITLE>My Title</TITLE> <!-- Page title -->
</HEAD>
<!-- Body -->
<BODY>

<!-{ 2,} matches the start of the comment, <! followed by two or more hyphens. .*? matches the comment body (not greedy). -{ 2,} > matches the end of the comment.

  • + Share This
  • 🔖 Save To Your Account