首页 > 其他分享 >HTML 10 - Comments

HTML 10 - Comments

时间:2024-05-18 13:40:50浏览次数:22  
标签:comment 10 use Comments will HTML Comment

HTML Comments are used to comment in HTML codes, so the developer can understand the purpose of that code section and it is helpfull for debugging also. If we are facing some issue becouse of any particular element we cah check it by commenting out that element.

What are HTML Comments?

HTML comment tag is used to create a comment. A comment in HTML is like a note for yourself and others. Comments are completely ignored by web browsers, so they don't affect how your page looks or works. There are two types of comment in HTML.

  • Single Line Comment: The single-line comment is given inside the <!-- ... -->.
  • Multi Line Comment: Same as single-line comment but if we add multiple lines in the comment we will have multi-line comments.

Why to use HTML Comments?

Comments help you and others to understand the code and increases code readability. HTML comments are placed in between <!-- ... --> tags. So, any content placed with-in <!-- ... --> tags will be treated as comment and will be completely ignored by the browser.

 

Examples of HTML Comments

In the bellow examples we will witness single and multiline both types of comments.

HTML Single Line Comment

Here in this example we will use single line comment for each element used in the body tag.

<!DOCTYPE html>
<html>
<head>
    <title>Online HTML Editor</title>
</head>
<body>
    <!-- This is a single Comment-->
    <h1>Tutorialspoint</h1>
    <!-- This is a single line Commnet -->
    <p>Simply Easy Learning</p>
</body>
</html>

 

HTML Multi Line Comment

Here in this example we will use multi line comment for each element used in the body tag.

<!DOCTYPE html>
<html>
<head>
    <title>Online HTML Editor</title>
</head>
<body>
    <!-- 
       This is a multiline Comment
       Heading Section
    -->
    <h1>Tutorialspoint</h1>
    <!-- 
       This is a multiline line Commnet 
       paragrapgh Scetion 
    -->
    <p>Simply Easy Learning</p>
</body>
</html>

 

Note: We can not use the above approach of commenting on internal CSS and JavaScript section. In the <style> and <script> tag we have to use CSS and JavaScript comment syntax.
 

Hide Content using HTML Comment

This is required when we will work on debugging HTML code, this will help us to not to render specific html element.

<!DOCTYPE html>
<html>
<head>
    <title>Hiding p Element</title>
</head>
<body>
    <h1>Tutorialspoint</h1>
    <!--  <p>Simply Easy Learning</p> -->
</body>
</html>

Valid vs Invalid Comments

Comments in HTML have a single that you need to follow. You need make sure that there are no spaces in the start or end of comment string.

<!DOCTYPE html>
<html>
<head>
   <title>Valid & Invalid Comment</title>
</head>
<body>
   <!--   This is valid comment -->
   < !--   This is not a valid comment -->
   < !--   This is not a valid comment -- >
</body>
</html>

 

 

Conditional Comments

Conditional comments are a feature specific to Internet Explorer (IE) on Windows but they are ignored by other browsers. They are supported from Explorer 5 onwards, and you can use them to give conditional instructions to different versions of IE.

<!DOCTYPE html>
<html>
<head>
   <title>Conditional Comments</title>
   <!--[if IE 6]>
      Special instructions for IE 6 here
   <![endif]-->
</head>
<body>
   <p>Document content goes here.....</p>
</body>
</html>

 

 

 

标签:comment,10,use,Comments,will,HTML,Comment
From: https://www.cnblogs.com/emanlee/p/18190420

相关文章

  • 代码随想录算法训练营第第11天 | 20. 有效的括号 、1047. 删除字符串中的所有相邻重
    今天的题主要是关于栈的,比较简单,一次性过20.有效的括号讲完了栈实现队列,队列实现栈,接下来就是栈的经典应用了。大家先自己思考一下有哪些不匹配的场景,在看视频我讲的都有哪些场景,落实到代码其实就容易很多了。题目链接/文章讲解/视频讲解:https://programmercarl.com/0020.......
  • HTML 09 - Quotations
     QuotationsinHTMLallowyoutoincludeandformatquotedtextwithinyourwebcontent.HTMLprovidestagssuchas<blockquote>,<q>,<cite>,<address>,<bdo>and<abbr>tostructureandstylequotes.Thesetagshelp......
  • P1036 [NOIP2002 普及组] 选数
    传送锚点:https://www.luogu.com.cn/problem/P1036题目描述已知\(n\)个整数\(x_1,x_2,\cdots,x_n\),以及\(1\)个整数\(k\)(\(k<n\))。从\(n\)个整数中任选\(k\)个整数相加,可分别得到一系列的和。例如当\(n=4\),\(k=3\),\(4\)个整数分别为\(3,7,12,19\)时,可得全部的组合......
  • P10125 「Daily OI Round 3」Simple 题解
    题目传送门简单模拟,主要考察字符串。首先输入一个char类型的数组,然后直接遍历每一位是否为Acoipp或Svpoll即可。//Simple//codeby:cq_irritater//time:2024/02/04#include<bits/stdc++.h>usingnamespacestd;chara[10];intmain(){//freopen("......
  • P10409 「QFOI R2」水落溪流浅浅
    题目传送门一道简单字符串。这道题最简单的方法是使用字符串,但是由于本人不太喜欢使用字符串,所以使用了模拟的方法。首先,你可以根据题意写出如下的代码://「QFOIR2」水落溪流浅浅//codeby:cq_irritater//time:2024/05/04#include<bits/stdc++.h>usingnamespaces......
  • [USACO10OCT] Lake Counting S
    传送锚点:https://www.luogu.com.cn/problem/P1596由于近期的降雨,雨水汇集在农民约翰的田地不同的地方。我们用一个\(N\timesM(1\leqN\leq100,1\leqM\leq100)\)的网格图表示。每个网格中有水(W)或是旱地(.)。一个网格与其周围的八个网格相连,而一组相连的网格视为一个水坑。约......
  • Games101-3 triangle
    rasterize==drawingontothescreencolor=(red,green,blue)pixelindicesarefrom(0,0)to(width-1,height-1)pixel(x,y)iscenteredat(x+0.5,y+0.5)光栅化判断一个像素的中心点是否需要draw采样的方法--将函数离散化如果中心再三角形内。如何判断......
  • Games101-5 shadering
    shader对不同物体应用不同的材质定义:shading!=shadowdiffusereflection漫反射光照角度不同,则反射程度也不同于此同时物体离光源越远,反射程度越低高光项镜面反射和视线比较接近的时候使用半程向量计算高光注:半程向量比较好算,反射向量比较难算指数p:cos......
  • Games101-6 Geometry
    implicit--隐式几何explicit--显示几何implicit点不需要知道位置,但是可以用点之间的关系表示(按照类别归类)E.g.allpointsin3D,where$x2+y2+z^2=1$更通用的表示$f(x,y,z)=0$劣势:不直观优势:可以很简单的判断一个点是否再物体内或者外。explicit......
  • Games101-7 raytracing
    shadowmapping思想:光源可以看到点,人也可以看到的点。---不在shadow中的点只能处理点光源深度不一致浮点数的精度问题。软/硬阴影raytracing直线传播不会碰撞从光源出发,到人眼光线是可以反射的多次弹射的光纤追踪rayequation对隐式表面对显示......