如何對已經包含註解的 HTML 進行註解?

如何對已經包含註解的 HTML 進行註解?

當 HTML 部分已經有註解時,我無法註解掉這些部分。這是因為註解語法的結束標記衝突。有沒有 VS Code 擴充可以減輕我的困難?

答案1

據我所知,沒有擴展,因為 HTML 語法(或 SGML)不允許它。

作為僅在特殊情況下才應使用的解決方法(由於手動處理中的預期錯誤,您會收到警告),您可以使用以下方法:

<head>
<title>Garden</title>
<!-- this is some comment 

<!- - this is some inner comment - ->

<!- - this is some sibling comment - ->

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="garden, home, plant">
<meta name="MS-HKWD" content="tree">
<meta name="MS-HKWD" content="pond">
<meta name="MS-HKWD" content="fish">
<meta name="MS-HKWD" content="flowers">
<meta name="MS-HKWD" content="health">
<meta name="MS-HKWD" content="health, relax">
<meta name="MS-HAID" content="botany">
this is the footer of comment -->
<link href="../design.css" rel="stylesheet" type="text/css" />
</head>

或者您可能想使用特殊字元和類似的東西:

<!~~ this is some inner comment ~~>

相關內容