Comments inside HTML and CSS

Often, it’s a good idea to make comments in HTML and CSS code. These comments server the purpose to tell us in plain English what the code actually is, or does. There is various syntax we can use to show comments that are essentially ignored by the browser (it doesn’t see your comments as actual code).

In HTML here is an examples of comment syntax.

<!DOCTYPE html>
    <title>My website</title>
   <meta charset="UTF-8">
   <link rel="stylesheet" a href="style.css">
      <!-- This section shows us the latest deals -->
        <h2>Latest Deals</h2>
        <h3>See latest holiday deals here</h3> 
          <h4>Holiday 1</h4>
          <h3 class="holiday_break_title">See holiday break number 1</h3>
          <p>A lovely break in spain</p>

We can see that we can write anything inbetween <!– and –>

In css the syntax is a little bit different, as shown below.

h2 {
  color: blue;
  font-size: 40px;
  margin: 50px; /* margin of 50px around h2 text */
  background-color: yellow; /* yellow background */
  text-align: center; /* center the text */

In CSS we have to use /* and a closing */ around any comments.

Leave a Reply