简体   繁体   English

是什么 <!— --> 以html表示

[英]What does <!— --> In html mean

So in html you frequently see 所以在html中,您经常看到

<!-- HTML TEXT HERE -->

What is the purpose of Greater than exclamation mark double hyphens and double hyphen less than ? 大于感叹号双连字符和小于双连字符的目的是什么?

These are comments , that are not visible to the user but only when you view the actual HTML. 这些是注释 ,仅当您查看实际的HTML时对用户不可见。

They are also useful in commenting out a block of code when you're doing testing, that way you can prevent from having to cut and paste the code else where, and then copy them back. 在执行测试时,它们在注释掉一段代码时也很有用,这样可以避免将代码剪切并粘贴到其他位置,然后再复制回去。

Additionally, some developers used them to 'hide' code, usually in scripts, to avoid a chunk of code displayed for browsers that disable Javascript. 另外,一些开发人员使用它们来“隐藏”通常在脚本中的代码,以避免为禁用Javascript的浏览器显示大量代码。

<script>
<!--
function displayMsg() {
    alert("Hello World!")
}
//-->
</script> 

That will prevent code from function .... to } from showing up on browsers that have Javascript disabled. 这样可以防止function ....}代码显示在禁用Javascript的浏览器上。 You'll also frequently see tags. 您还将经常看到标签。

It is also used for conditional comments , which are only supported in Internet Explorer, whereby you adapt your HTML to legacy browsers like IE6, so your shiny website doesn't break on old browsers. 它也用于条件注释 ,只有Internet Explorer才支持它,从而使HTML适应IE6等旧版浏览器,这样,闪亮的网站就不会在旧版浏览器上损坏。 See here for more info . 有关更多信息,请参见此处

Here's an example of conditional comments you might see: 这是您可能会看到的条件注释的示例:

<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->

That means if Internet Explorer is Version 8 (old and outdated) load that stylesheet. 这意味着如果Internet Explorer是版本8(旧的和过时的),则加载该样式表。

For more information about comments, this is a good tutorial . 有关注释的更多信息, 这是一个很好的教程

Those are HTML Comments. 这些是HTML注释。

Like comments in code, you can use them to describe why you're doing what you're doing in your markup so save the next guy to work on your code a whole lot of headaches. 就像代码中的注释一样,您可以使用它们来描述为什么要在标记中执行操作,因此省去了下一个要处理代码的人的麻烦。

They are comments. 他们是评论。
comments are for describing your code so if other programmers(or even yourself!) want to see what it's used for,it'll make it more easy to understand. 注释用于描述您的代码,因此,如果其他程序员(甚至您自己!)想要查看它的用途,则将使其更易于理解。
comments are used in all programming languages.in html, comments are <!-- Comments --> but in other languages Comments are //comments... or /* comments...*/ so don't get confused if you see them. 在所有编程语言中都使用注释。在html中,注释是<!-- Comments -->但在其他语言中,注释是//comments.../* comments...*/因此,不要混淆看他们。
THIS article will show you why we use comments in different programming languages. 文章会告诉你为什么,我们使用不同的编程语言注释。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM