How to use comments nested in html

Many people will find that when using the nested comments of html, they will find that it cannot achieve the effect we thought. Internet search failed, and suddenly found a way to realize the nested use of comments in html.

If we use nested comments in html↓

 <!-- 这是一个注释 <!-- 这是注释中的注释 --> -->  

Then the situation after running is like this↓

Insert picture description here
This obviously did not achieve the purpose we wanted.
Here is the correct way to use it:

<!-- 这是一个注释 <!-- 这是注释中的注释 -> -->

Insert picture description here

As shown in the figure above, as long as you hit one less "-" in the inner nest, it's fine

Complete code:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>HTML如何嵌套使用注释</h1>
		
		<p>嵌套的错误使用方式↓</p>
		<!-- 这是一个注释 <!-- 这是注释中的注释 --> -->  
		
		<p>嵌套的正确使用方式↓</p>
		<!-- 这是一个注释 <!-- 这是注释中的注释 -> -->
		
		<p>嵌套的正确使用方式↓</p>
		<!-- 
		这是一个注释
		
		 <!-- 这是注释中的注释  ->
		  
		-->  
		  <p>这是一段话</p>
	</body>
</html>

running result:
Insert picture description here
You will be smart, thank you for your support!
Insert picture description here
Come on!

Work together!

Keafmd

Guess you like

Origin blog.csdn.net/weixin_43883917/article/details/109320481