html怎么注釋掉代碼
HTML中的注釋 (Comments in HTML)
The comment tag is an element used to leave notes, mostly related to the project or the website. This tag is frequently used to explain something in the code or leave some recommendations about the project. The comment tag also makes it easier for the developer to come back and understand the code he’s written at a later stage. Comments can also used for commenting out lines of code for debugging purposes.
comment標簽是用于留下筆記的元素,主要與項目或網站有關。 該標簽通常用于解釋代碼中的某些內容或對項目提出一些建議。 comment標簽還使開發人員可以更輕松地返回并了解他在稍后階段編寫的代碼。 注釋還可以用于注釋掉代碼行以進行調試。
It is good practice to add comments to your code, especially when working with a team or at a company.
最好在代碼中添加注釋,特別是在與團隊或公司合作時。
Comments are started with <!--
and ended with -->
, and can span multiple lines. They can contain code or text, and won’t appear on the front-end of the website when a user visits a page. You can view comments through the Inspector Console, or by viewing Page Source.
注釋以<!--
開頭,以-->
結尾,并且可以跨越多行。 它們可以包含代碼或文本,并且當用戶訪問頁面時不會出現在網站的前端。 您可以通過Inspector控制臺或通過查看頁面源來查看注釋。
例 (Example)
<!-- You can comment out a large number of lines like this.
Author: xyz
Date: xx/xx/xxxx
Purpose: abc
-->
Read more: https://html.com/tags/comment-tag/#ixzz4vtZHu5uR
<!DOCTYPE html>
<html><body><h1>FreeCodeCamp web</h1><!-- Leave some space between the h1 and the p in order to understand what are we talking about--><p>FreeCodeCamp is an open-source project that needs your help</p><!-- For readability of code use proper indentation --></body>
</html>
有條件的評論 (Conditional Comments)
Conditional Comments defines some HTML tags to be excuted when a certain codition is fullfilled.
條件注釋定義了一些HTML標記,當某個條件完成時,這些標記將被執行。
Conditional Comments are only recognised by Internet Explorer Version 5 through to Version 9 - IE5 - IE9.
Internet Explorer版本5到版本9-IE5-IE9僅可識別條件注釋。
例 (Example)
<!DOCTYPE html>
<html><body><!--[if IE 9]><h1>FreeCodeCamp web</h1><p>FreeCodeCamp is an open-source project that needs your help</p> <![endif]--></body>
</html>
IE條件注釋 (IE Conditional Comments)
These comments are only available in Internet Explorer and can be used up to IE9. In the current times, there is a good change you will never see them, but it is good to know about their existance. Conditional comments are a way to serve a different experience for different client browsers. For example:
這些注釋僅在Internet Explorer中可用,并且最多可用于IE9。 當前,有一個很好的變化,您將永遠不會看到它們,但是很高興知道它們的存在。 條件注釋是一種為不同的客戶端瀏覽器提供不同體驗的方法。 例如:
<!--[if lt IE 9]> <p>Your browser is lower then IE9</p> <![endif]-->
<!--[if IE 9]> <p>Your browser is IE9</p> <![endif]-->
<!--[if gt IE 9]> <p>Your browser is greater then IE9</p> <![endif]-->
有關HTML的更多信息: (More info on HTML:)
Beginner's guide to HTML
HTML入門指南
Best HTML and HTML5 tutorials
最佳HTML和HTML5教程
The HTML Handbook
HTML手冊
翻譯自: https://www.freecodecamp.org/news/html-comments-how-to-comment-out-your-html-code/
html怎么注釋掉代碼