title: Which to use <div class="name"> or <div id="name">?
body: <p>I am learning HTML. Can someone please tell me what is the difference between class and id and when to use one over the other? They seem to do the same thing</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;style&gt;
  
  #mycolor1 {color: red;}    
  .mycolor2 {color: red;}
  
  &lt;/style&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div id="mycolor1"&gt;     hello world &lt;/div&gt;
  &lt;div class="mycolor2"&gt;     hello world &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>