Comments in HTML are often used to explain markup. When editing source code, it will help you and others quickly and easily select or find specific parts of the document. The browser will not display comments.
HTML comments start with .
The code examples are as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Comments in HTML</title> </head> <body> <!-- 这是单行HTML注释 --> <!-- 这是一个例子 HTML多行注释 --> <h1>这是标题</h1> <p>这是一个段落。</p> </body> </html>
In short, HTML comments are codes that are not executed by the program. Used by programmers to mark up code.
When writing HTML code, we often need to make comments next to some key codes. This has many benefits, such as: it is easier to understand, easier to find, or easier for other programmers in the project team to understand your code. , and it will make it easier for you to modify your code in the future.
This article is an introduction to HTML comments. It is very simple and easy to understand. I hope it will be helpful to novices!
The above is the detailed content of How to comment in html. For more information, please follow other related articles on the PHP Chinese website!