HTML Comments


Before we go ahead in this chapter we need to understand one thing that whether we are learners or professionals, we have to write massive codes to learn or to built a web site. If we think programming or coding is required less amount of work or efforts then we are wrong. A huge amount efforts and cods are required to build a little app. We need to remember and understand the codes on HTML documents.

For example we can look at the Facebook. Facebook started in 2004 but even in the starting period it was not too simple to code. It was a group effort and now FB is an ocean of codes.

Why HTML Comments are used?


When a developer builds a website then he needs to remember the use of the codes. In other words we can say why particular code is placed at particular location of the document is must be remembered by the developer. If he doesn’t understand the purpose of the code then he might be confused while he is trying to debug the codes. It is almost impossible for a developers to keep remember those massive codes. Therefore Programmers and Developers use the comments.

Comments are the set of information or notifications that defined by the developers which is not displayed by the web browsers and they help the developers to understand the source code.

Example - 1


<!--This is an HTML comment-->

Above code is not rendered on web page and stay invisible

How HTML Comments are used

To use HTML comment we need to define opening tag with “<! --“. After that we can write information and notifications and define closing tag “-- >”. Likely you can see in below example.

Example - 2


<div class="dropdown-menu">
 <a class="dropdown-item" href="#">HTML-5 Tutorial</a>
 <a class="dropdown-item" href="#">CSS Tutorial</a>
 <a class="dropdown-item" href="#">JS Tutorial</a>
 <!--
 <a class="dropdown-item" href="#">PHP Tutorial</a> -- Not Displayed on web page --
 -->
 <a class="dropdown-item" href="#">JQuery Tutorial</a>
 <a class="dropdown-item" href="#">NodeJS Tutorial</a>
</div>


Comment usually looks in Green color on HTML document but some text editor uses different color.
Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for errors.

Conditional Comments

Many website use feature detection techniques to ensure their site provide different experience for browsers of different capabilities. Some of the web sites use server or client side script to detect the browser version but some use conditional comments which is supported by Internet Explorer only. Conditional comments make it easy to detect earlier versions of Windows Internet Explorer. Conditional comments are the preferred means of differentiating Cascading Style Sheets (CSS) rules intended for specific versions of Internet Explorer.

Internet Explorer Version below IE5 is referred as downlevel browser. IE version above then 5 is called uplevel browsers. A block conditional comment that is ignored by downlevel browsers is referred as downlevel- hidden and a block conditional comment that is parsed by downlevel browsers is referred as downlevel- revealed.

Syntax of conditional comments


Comment Type Syntax or possible Value
Standard HTML Comment <!--Comment Content-->
Downlevel-Hidden <!--[if expression]>HTML <![endif]-->
Downlevel-Revealed <![if expression]>HTML <![endif]>




Example - 3


Example 1.1
<!--[if IE 8]>
<p>Welcome to Internet Explorer 8.</p>
<![endif]-->

Example 1.2
<!--[if gte IE 7]>
<script>
  alert("Congratulations! You are running Internet Explorer 7 or a later version of Internet Explorer.");
</script>
<p>Thank you for closing the message box.</p>
<![endif]-->


Tips: Conditional Comments are no longer supported from Internet Explorer 10. To test all given examples of conditional comment you must have IE version below 10.

HTML5 Tutorial - HTML Comments

Related Topics

progrramers-logo

progrramers

Hello friends! Progrramers is a tutorial site of w3 programming. If you like this tutorial site please encourages us by sharing this site links with your friends and nears & dears who want to learn web development and give us like on our Facebook page. If have any question please type in to comment box or send us message on social media sites via below given social links. Thank you, have a nice learning.

Post A Comment:

29 comments:


  1. Excellent blog thank you for the info

    data science courses

    ReplyDelete
  2. If you are looking for more information about flat rate locksmith Las Vegas check that right away. antminer s17 setup

    ReplyDelete
  3. This is surely a very good blog, thanks a lot for sharing such nice information here.
    web-site

    ReplyDelete
  4. When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. Web design Singapore

    ReplyDelete
  5. Hey There. I found your blog using. This is an extremely well written article. I’ll be sure to bookmark it and return to read more of your useful info. Thanks for the post. I’ll definitely comeback.
    magento developers melbourne

    ReplyDelete
  6. Its fantastic as your other blog posts : D, thanks for posting . web design manhattan

    ReplyDelete
  7. Great post! I?m just starting out in community management/marketing media and trying to learn how to do it well – resources like this article are incredibly helpful. As our company is based in the US, it?s all a bit new to us. The example above is something that I worry about as well, how to show your own genuine enthusiasm and share the fact that your product is useful in that case web design new york

    ReplyDelete
  8. Greetings! This is my first comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading through your blog posts. Can you recommend any other blogs/websites/forums that deal with the same topics? Thank you so much! branding agencies in san francisco

    ReplyDelete
  9. We make sure to give you what you are looking for as we focus on stability and adaptability to engage your target market. website development company in usa

    ReplyDelete
  10. I must say, as a lot as I enjoyed reading what you had to say, I couldnt help but lose interest after a while. Its as if you had a wonderful grasp on the subject matter, but you forgot to include your readers. Perhaps you should think about this from far more than one angle. Or maybe you shouldnt generalise so considerably. Its better if you think about what others may have to say instead of just going for a gut reaction to the subject. Think about adjusting your own believed process and giving others who may read this the benefit of the doubt. web design san francisco

    ReplyDelete
  11. Aliza Solutions is one of the most established and trusted digital agencies who can help you achieve your business goals with our strategic design and development skills. web development services in usa

    ReplyDelete
  12. hello, your website is really good. We do appreciate your give good results web designer san francisco

    ReplyDelete
  13. Keep up the fantastic piece of work, I read few blog posts on this web site and I believe that your site is real interesting and has lots of great information. web design san francisco

    ReplyDelete
  14. I believe one of your commercials caused my browser to resize, you may well want to put that on your blacklist. website design firms san francisco

    ReplyDelete
  15. I’m not that much of a internet reader to be honest but your blogs really nice, keep it up! I’ll go ahead and bookmark your site to come back in the future. All the best web design agency san francisco

    ReplyDelete
  16. It’s great page, I was looking for something like this web design agency san francisco

    ReplyDelete
  17. For your data, there are 2 sorts of uptime with regards to web facilitating. One is the thing that we called the Network Uptime and the other one is known as the Server Uptime.
    web hosting near me

    ReplyDelete
  18. Well done – It really takes a lot of time to have blog posts. While I don’t agree on your blog I will concede that your are entitled to have your own perspective. The site ended up having some cool perspectives. Cool work job– web design agencies los angeles

    ReplyDelete
  19. We still cannot quite feel like I made it worse come to be the staring at the important points located on your webblog. My in laws so i are sincerely thankful for use in your generosity and then for giving me possibility pursue our chosen profession path. Document important info Managed to get with the web-site. la web design

    ReplyDelete
  20. being an entrepreneur opened up lots of business leads on my line of work, i like to make money both online and offline** web designer los angeles

    ReplyDelete
  21. The article posted was very informative and useful. You people are doing a great job. Keep going. web design agency

    ReplyDelete
  22. What is your most noted accomplishment. They may want good listeners rather than good talkers. web design tips

    ReplyDelete
  23. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    It courses

    ReplyDelete
  24. When posting your undertaking, ensure you select a class that appropriately distinguishes your sort of venture. In the event that your task is identified with article composing, it ought to be posted in that classification or a comparative one.Professional graphic design

    ReplyDelete
  25. If you are looking for a website design company in your local area simply type in to Google "website design" + your locality, for example website design in Lincoln. Elementor Experts

    ReplyDelete
  26. I wish more authors of this type of content would take the time you did to research and write so well. I am very impressed with your vision and insight. aktieanalys

    ReplyDelete
  27. You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. Web Developer Gold Coast

    ReplyDelete
  28. Very good written article. It will be supportive to anyone who utilizes it, including me. Keep doing what you are doing – can’t wait to read more posts.
    nodejs software developers

    ReplyDelete