html - What is the use of this syntax: <!---->? -


i've been working design ui of our website , looking templates available in web.

then encountered syntax <!----> , i'm not familiar it.

can please tell me , used for?

thank you.

as other posts have mentioned <!----> code in html used adding comments - note left in code developer info other developers, or remember themselves. code viewable in source not displayed when viewing html in browser. ex:

<!-- need update each year --> <div>&copy; 2009 - 2016</div> 

will produce:

© 2009 - 2016 

in cases comment can removed no side-effect on code. it's note developers.

other uses

commenting out code
in addition comments you'll see html code wrapped <!---->. ex:

<!-- add later   <img src="article.jpg" alt="article"> --> 

the above code remove entire image tag browser view. useful if want temporarily remove html page, testing/debugging or later use. you'll see entire html sections commented out.

conditional code
common use of comments add conditional code used specific browsers. following snippet of code read internet explorer 8, , apply black background color body.

<!--[if ie 8]>   <style>     body {       background-color: black;     }   </style> <![endif]--> 

website builders
website builders generate own code comments internal use. example, if use squarespace generated code contain comments like:

<!-- squarespace. --><!-- www --> 

these snippets, in cases, used generators marker inserting other code.

build scripts
there's small chance comment tag being used part of build script, , in case removing cause issues. here's example:

<!-- build:css --> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/main.css"> <!-- endbuild --> 

the above code, used build system gulp , gulp plugin html replace replace content between <!-- build:css--> , <!-- endbuild --> tags new code. removing either 1 of comment tags cause errors.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -