Comments

Often, to make your code more readable, you would want to add comments to it, but not have them render in the browser. This is done by enclosing a comment in <!-- and -->. E.g., this code snipped:

<!-- Lenke til it2805.github.com -->
<a href="http://it2805.github.com">IT2805</a>

would render:

IT2805

This is often used when it is not clear from the code what is going on, or you want to make it easy to see what opening and closing tags belong together. Speaking by experience, you may get lost in the number of divs, and which closing tags belong to which opening tags. E.g.:

<div id="content">
  <div id="header">
  </div> <!-- /header -->
  <div id="body">
    ...
  </div> <!-- /body -->
</div> <!-- /content -->

In this case /header means that this is the end of the header tag.

Comments are also useful to quickly make code not render, in cases you want to see the difference without actually deleting the code.

Suddenly I introduced the div element. This is an element which does not represent anything. It is used to group elements together, most often for styling purposes using CSS. You will see a lot more of it in chapter 7. As the div element does not have any semantic meaning it should only be used when no other semantic element (such as <article> or <footer>) is appropriate (more on these semantic elements two sections down).

Last updated