Please Allow Notifications

If you want to get our blog posts notification, you can subscribe our website by clicking on allow notification button



FOLLOW US ON TWITTER



FOLLOW US



img/blogimg/html5.jpg


@harish 868

Comments in HTML


2021-11-17 13:18 · 5 min read

Comments in HTML

Similar to other programming, markup, and markdown languages, comments in HTML provide other developers with development-specific information without affecting the user interface. Unlike other languages, however, HTML comments can be used to specify HTML elements for Internet Explorer only. This topic explains how to write HTML comments and their functional applications

 

Creating comments

HTML comments can be used to leave notes to yourself or other developers about a specific point in code. They can be initiated with <!--and concluded with -->, like so:


 

<!-- I'm an HTML comment! -->

They can be incorporated inline within other content:


 

<h1>This part will be displayed <!-- while this will not be displayed -->.</h1>

 

They can also span multiple lines to provide more information:


 

<!-- This is a multiline HTML comment.
Whatever is in here will not be rendered by the browser.
You can "comment out" entire sections of HTML code.
-->

 

However, they cannot appear within another HTML tag, like this:


 

<!-- This is a multiline HTML comment.
Whatever is in here will not be rendered by the browser.
You can "comment out" entire sections of HTML code.
-->

 

However, they cannot appear within another HTML tag, like this:

 

Note:- However, they cannot appear within another HTML tag, like this:

<h1 <!-- testAttribute="something" --> >This will not work</h1>

 

This produces invalid HTML as the entire <h1 <!-- testAttribute="something" -->block would be considered a single start tag h1 with some other invalid information contained within it, followed by a single > closing bracket that does nothing.

For compatibility with tools that try to parse HTML as XML or SGML, the body of your comment should not contain two dashes --.

Commenting out whitespace between inline elements:-

Inline display elements, usually such as span or a, will include up to one white-space character before and after them in the document. In order to avoid very long lines in the markup (that are hard to read) and unintentional white-space (which affects formatting), the white-space can be commented out

<!-- Use an HTML comment to nullify the newline character below: -->
<a href="#">I hope there will be no extra whitespace after this!</a><!--
--><button>Foo</button>

 

Try it without a comment between the inline elements, and there will be one space between them. Sometimes picking up the space character is desired.

Example code:

<!-- Use an HTML comment to nullify the newline character below: -->
<a href="#">I hope there will be no extra whitespace after this!</a>
<!--
--><button>Foo</button>
<hr>
<!-- Without it, you can notice a small formatting difference: -->
<a href="#">I hope there will be no extra whitespace after this!</a>
<button>Foo</button>

 

 

TAGS:






POST COMMENTS
No Comment

Please login to post comment




POPULAR POSTS

what is new in miui 11?...
best free web hosting services...
free website ssl security using cloudfla...
do you want to make money online?...
CSS3 @IMPORT RULES...
CSS3 RESPONSIVE UI...
Tables HTML...
How to host a web page in 10 minutes....
How to use CSS3 Overflow Property?...
CSS3 FUNCTIONS...
CSS3 FILTERS...
CSS3 SHAPES...


RECENT COMMENTS

2022-03-05 11:05
By coder on XAMPP - MySQL shutdown unexpectedly | How to fix MySQL crash unexpectedly
2021-10-12 12:34
By abnongoke on do you want to make money online?
2021-10-12 12:34
By abnongoke on how to get a free website domain name?
2021-10-12 12:34
By solar panel for shed on what is new in miui 11?
2021-10-12 12:34
By solar panel for shed on best free web hosting services
2021-10-12 12:34
By amos tanui on free website ssl security using cloudflare


SOCIAL SHARE



FOLLOW US ON TWITTER



FOLLOW US ON FACEBOOK



FOLLOW US







Recent Blogs



Contact Us

Subscribe Our News-Letter



Kashipur, 244713
Uttarakhand, India



© blog.theprodevelopers.com 2022. All Rights Reserved. Powered by Pro Developer