0% found this document useful (0 votes)
47 views4 pages

14 HTML - Comments

A HTML - Comments

Uploaded by

AGBA TERKUMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views4 pages

14 HTML - Comments

A HTML - Comments

Uploaded by

AGBA TERKUMA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

7/17/24, 11:04 AM HTML - Comments

HTML - Comments
HTML Comments are used to comment in HTML codes, so the developer can understand
the purpose of that code section and it is helpfull for debugging also. If we are facing
some issue becouse of any particular element we cah check it by commenting out that
element.

What are HTML Comments?


HTML comment tag is used to create a comment. A comment in HTML is like a note for
yourself and others. Comments are completely ignored by web browsers, so they don't
affect how your page looks or works. There are two types of comment in HTML.

Single Line Comment: The single-line comment is given inside the <!-- ... -->.

Multi Line Comment: Same as single-line comment but if we add multiple lines in
the comment we will have multi-line comments.

Why to use HTML Comments?


Comments help you and others to understand the code and increases code readability.
HTML comments are placed in between <!-- ... --> tags. So, any content placed with-in
<!-- ... --> tags will be treated as comment and will be completely ignored by the
browser.

Try to click the icon run button to run the following HTML code to see the output.

Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.

Examples of HTML Comments


In the bellow examples we will witness single and multiline both types of comments.

HTML Single Line Comment

Here in this example we will use single line comment for each element used in the body
tag.

https://www.tutorialspoint.com/html/html_comments.htm 1/4
7/17/24, 11:04 AM HTML - Comments

Open Compiler

<!DOCTYPE html>
<html>
<head>
<title>Online HTML Editor</title>
</head>
<body>
<!-- This is a single Comment-->
<h1>Tutorialspoint</h1>
<!-- This is a single line Commnet -->
<p>Simply Easy Learning</p>
</body>
</html>

HTML Multi Line Comment


Here in this example we will use multi line comment for each element used in the body
tag.

Open Compiler

<!DOCTYPE html>
<html>
<head>
<title>Online HTML Editor</title>
</head>
<body>
<!--
This is a multiline Comment
Heading Section
-->
<h1>Tutorialspoint</h1>
<!--
This is a multiline line Commnet
paragrapgh Scetion
-->
<p>Simply Easy Learning</p>
</body>
</html>

https://www.tutorialspoint.com/html/html_comments.htm 2/4
7/17/24, 11:04 AM HTML - Comments

Note: We can not use the above approach of commenting on internal CSS and
JavaScript section. In the <style> and <script> tag we have to use CSS and
JavaScript comment syntax.

Hide Content using HTML Comment


This is required when we will work on debugging HTML code, this will help us to not to
render specific html element.

Open Compiler

<!DOCTYPE html>
<html>
<head>
<title>Hiding p Element</title>
</head>
<body>
<h1>Tutorialspoint</h1>
<!-- <p>Simply Easy Learning</p> -->
</body>
</html>

Valid vs Invalid Comments


Comments in HTML have a single that you need to follow. You need make sure that there
are no spaces in the start or end of comment string.

Open Compiler

<!DOCTYPE html>
<html>
<head>
<title>Valid & Invalid Comment</title>
</head>
<body>
<!-- This is valid comment -->
< !-- This is not a valid comment -->
< !-- This is not a valid comment -- >

https://www.tutorialspoint.com/html/html_comments.htm 3/4
7/17/24, 11:04 AM HTML - Comments

</body>
</html>

Conditional Comments
Conditional comments are a feature specific to Internet Explorer (IE) on Windows but they
are ignored by other browsers. They are supported from Explorer 5 onwards, and you can
use them to give conditional instructions to different versions of IE.

Open Compiler

<!DOCTYPE html>
<html>
<head>
<title>Conditional Comments</title>
<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->
</head>
<body>
<p>Document content goes here.....</p>
</body>
</html>

https://www.tutorialspoint.com/html/html_comments.htm 4/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy