包括:HTML、CSS、php、JavaScript
HTML注釋
注意:html 注釋標籤和其它語言的注釋不一樣。比如:JavaScript、php等語言都有單行注釋和多行注釋,但是 html 注釋標籤只有一個,單行和多行都是使用同一個標籤來注釋。
<!-- 這裡是注釋的內容 -->
<!-- 此刻不顯示圖片:
<img border="0" src="/i/tulip_ballade.jpg" alt="Tulip">
-->
注意: 注釋中可以直接使用回車換行。
並且我們習慣用注釋的標籤把HTML代碼包裹起來。如:
<!-- xx部分 開始 -->
這裡放你xx部分的HTML代碼
<!-- xx部分 結束 -->
HTML注釋的注意事項:
- HTML注釋不支持嵌套。
- HTML注釋不能寫在HTML標籤中
建議:
注釋的內容兩邊留個空格
不好:
<!--This section is non-normative-->
推薦:
<!-- This section is non-normative -->
多行注釋:
範例:來源於wordpress 2020主題:
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Twenty
* @since 1.0.0
*/
PHP
單行注釋
單行注釋有兩種方式,分別是使用「#」和反斜杠「//」。
// 這是單行注釋
# 這也是單行注釋
提示:單行注釋中使用最廣泛是使用雙斜杠「//」來定義注釋。
多行注釋塊
/*
這是多行注釋塊
它橫跨了
多行
*/
提示:多行注釋不能相互嵌套使用。
當然,這種方式也可以作為單行注釋使用
/* echo "PHP 注釋"; */