Learn Basic HTML Complete Course part 20

1 min read

HTML Comments

Comments are some text or code written in your code to give an explanation about the code, and not visible to the user. Comments which are used for HTML file are known as HTML comments. Anything written between these tags will be ignored by the browser, so comments will not be visible on the webpage.

Comments of any code make code easy to understand and increase readability of code.

Comments are also part of the code, which gives an explanation of the code.



How to add comment In HTML

You can add comments in your HTML file using <! -- ... --> tag. So if you will write anything between theses comment tag that will be treated as comment and browser will not read it.

Syntax

<! -- Write commented text here -->  

📍The commented code will not be visible to a webpage, and hence you can use comment tag for documentation purpose, and debugging purpose:


Example

<!DOCTYPE html> 
<html> 
<!-- This is Header section --> 
<head> 
    <!-- Internal CSS --> 
    <style> 
        h2.test, p.test{ 
            text-align: center; 
            background-color: #f0f8ff; 
            font-size: 30px; 
            color: red; 
        } 
    </style> 
</head> 
 
<!-- This is body section, write code here which you want to display on web-page --> 
<body> 
    <!-- heading tag --> 
<h2 class="test">First WebPage</h2> 
 
<!-- Paragraph tag --> 
<p class="test">Write your Content here!!!</p> 
</body> 
</html>    

output:

First WebPage

Write your Content here!!!


You may like these posts

  • HTML LayoutsHTML layouts provide a way to arrange web pages in well-mannered, well-structured, and in responsive form or we can say that HTML layout specifies a way in which the we…
  • Global AttributesHTML global attributes are those attributes which are common for all HTML elements. The global attributes are supported by both standard and non-standard element.T…
  • HTML Ordered List | HTML Numbered ListHTML Ordered List or Numbered List displays elements in numbered format. The HTML ol tag is used for ordered list. We can use ordered lis…
  • HTML ImageHTML img tag is used to display image on the web page. HTML img tag is an empty tag that contains attributes only, closing tags are not used in HTML image element.Let's s…
  • HTML ElementsAn HTML file is made of elements. These elements are responsible for creating web pages and define content in that webpage. An element in HTML usually consist of a sta…
  •  Introduction of HTMLHTML – HyperText Markup Language – The Language of Web Pages on the World Wide Web. 🔹HTML is a text formatting language.URL – Uniform Resource Locat…

Post a Comment