首頁 > web前端 > html教學 > 我們如何在HTML程式碼中新增評論?

我們如何在HTML程式碼中新增評論?

WBOY
發布: 2023-08-19 19:29:29
轉載
1892 人瀏覽過

我們如何在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 () tag.

Let’s look into the following example

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 com (" >") 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>
登入後複製

在執行上述腳本後,它將在網頁上產生包含腳本中使用的文字的輸出。

使用標籤

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

Example

的中文翻譯為:

範例

查看下面的範例,我們正在使用標籤。

<!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中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板