What does In html mean

These are comments, that are not visible to the user but only when you view the actual 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.

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

That will prevent code from function .... to } from showing up on browsers that have Javascript disabled. 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. 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.

For more information about comments, this is a good tutorial.

Leave a Comment