我们如何在HTML代码中添加评论?

WBOY
发布: 2023-08-19 19:29:29
转载
2350人浏览过

我们如何在html代码中添加评论?

In this article we are going to learn about how do we add a comment in HTML code. Let’s dive into the article for getting better understanding on adding comment in HTML code.

要在HTML代码中添加注释,请使用注释标签(!— Comment—>)。这是一种良好的编码实践,使编码人员和读者都能从理解代码的帮助中受益。理解复杂代码的步骤非常有帮助。在调试代码时,注释标签非常有用。

  • It is a straightforward bit of code that web browsers wipe off (ignore), meaning they do not appear.

  • Understanding the purpose of a piece of code, particularly in complex source code, is helpful to both coders and readers.

    立即学习前端免费学习笔记(深入)”;

Syntax

Following is the syntax for comment in HTML

<!-- Comments here -->
登录后复制

Let’s consider the following examples to get clear idea on how do we add a comment in HTML code.

单行注释

Single line comment is given inside the (<!—comment --->) tag.

Let’s look into the following example

Eva Design System
Eva Design System

基于深度学习的色彩生成器

Eva Design System 86
查看详情 Eva Design System

Example

的中文翻译为:

示例

In the following examples we are using the single line comment.

<!DOCTYPE html>
<html>
<body>
   <!--This is heading Tag, It wont be displayed by browser -->
   <h1>TutorialsPoint</h1>
   <!--This is paragraph tag,it won't be displayed by browser -->
   <p>The Best E-Way Learning</p>
</body>
</html>
登录后复制

当脚本执行时,它将生成一个输出,在网页上显示没有注释的文本。

Multi-line Comment

The syntax (!- ->) can be used to specify several lines. In essence, it is the same as the syntax for single-line comments; the only difference is that the first half of the comment ("->") is appended when the intended comment line ends.

Example

的中文翻译为:

示例

Considering the following example, where we are using the multi line comment tag.

<!DOCTYPE html>
<html>
   <body>
      <!-- This isheading tag -->
      <h1>MSD</h1>
      <!-- This is multi-linecomment tag -->
      <h2>The Best Finisher</h2>
   </body>
</html>
登录后复制

运行上述脚本后,它将在网页上生成包含脚本中使用的文本的输出。

使用<comment>标签

An HTML "comment" tag once existed, but none of the current browsers support it.

Example

的中文翻译为:

示例

查看下面的示例,我们正在使用<comment>标签。

<!DOCTYPE html>
<html>
   <body>
      <comment>Heading tag</comment>
      <h1>DUCATI</h1>
      <comment>Paragraph tag</comment>
      <h2>The Fastest Bike</h2>
   </body>
</html> 
登录后复制

When the script gets executed, it will generate an output displaying the text used in the code on the webpage along with the comments used by tag as modern browsers won’t support it.

以上就是我们如何在HTML代码中添加评论?的详细内容,更多请关注php中文网其它相关文章!

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:tutorialspoint网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号