HTML and CSS Comments

·

2 min read

HTML and CSS Comments

Comments are used too provide explanations, notes, or reminders for yourself and other programmers, you can add text comments to your code. Comments simply say, "Leave this line or lines out, do not run it."

This is why they have no impact on how a program behaves, because they will not be read or executed by your computer. They are meant to be read by people, such as you and any other programmers who could interact with or evaluate your code.

Within the code itself, comments are a way to express your ideas and goals. They can provide directions for using the code, or assist you and others with understanding the meaning of specific areas of the code.

How to Write Comments in HTML

<!-- I am a HTML Comment -->

<!-- Below is a html line of code -->

<h2>Mr. Bugs Bunny</h2>

<!-- Below is the same html code but a commented one -->
<!-- <h2>Mr. Bugs Bunny</h2> -->

<!-- Below is a multiple line html code -->
 <p>Writer, artist space enthusiats, in love with the stars</p>
  <button type="button ">Follow</button>

<!-- And below is that multiple line of code commented out -->
<!--
 <p>Writer, artist space enthusiats, in love with the stars</p>
  <button type="button ">Follow</button>
 -->

So there we have examples of comments in HTML. "<!-- -->" with code or text placed between is what defines a HTML comment.

How to Write Comments in CSS

/*I am a CSS comment and below is css code*/
body {
  background-color: orange;
}

/*Below I will be commenting the single-line css code above */

/* body {
  background-color: orange;
} */

"/* */" with code or text placed between is what defines as a CSS comment.

References:

HTML Comments (w3schools.com)

CSS Comments (w3schools.com)

#20daysinFrontendwithAA