HTML 注释
htmlweb developmentfront end technology更新于 2025/11/25 5:32:17
HTML 注释位于 <!-- ... --> 标签之间。因此,任何位于 <!-- ... --> 标签内的内容都将被视为注释,并会被浏览器完全忽略。
HTML 中的单行注释
示例
让我们看一个 HTML 中单行注释的示例 −
<!DOCTYPE html> <html> <head> <!-- 文档标题开始 --> <title>这是文档标题</title> </head> <!-- 文档标题结束 --> <body> <p>文档内容在此处.....</p> </body> </html>
输出
这将产生以下输出。注释中的文本不会被打印 −

HTML 中的多行注释
示例
我们也可以在 HTML 中设置多行注释。让我们来看一个例子 −
<!DOCTYPE html> <html> <head> <!-- Document Header Starts --> <title>This is document title</title> </head> <!-- Document Header Ends --> <body> <h2>Heading Two</h2> <!-- This is a multiline comment and it can span through as many as lines you like. --> <p>Document content goes here.....</p> <p>We have set comments in the document as well, but it won't get displayed.</p> </body> </html>
输出
这将产生以下输出。多行注释中的文本将不会显示 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

