title: Is it better to put the id attribute in a "a" tag or in the "h1/h2" tag?
body: <p>I'm learning html in w3 school website and I'm at the "html link" chapter. What I don't understand is why they propose using the id attribute in the link tag instead of the heading tag.</p>
  
  <p><strong>Their example:</strong></p>
  
  <pre><code>&lt;p&gt; 
  &lt;a href="#C4"&gt;See also Chapter 4.&lt;/a&gt;
  &lt;/p&gt;
  
  &lt;h2&gt;&lt;a id="C4"&gt;Chapter 4&lt;/a&gt;&lt;/h2&gt; 
  &lt;p&gt;This chapter explains ba bla bla&lt;/p&gt;
  </code></pre>
  
  <p><strong>My try:</strong></p>
  
  <pre><code>&lt;p&gt;
  &lt;a href="#C4"&gt;See also Chapter 4.&lt;/a&gt;
  &lt;/p&gt;
  
  &lt;h2 id="C4"&gt;Chapter 4&lt;/h2&gt;
  &lt;p&gt;This chapter explains ba bla bla&lt;/p&gt;
  </code></pre>
  
  <p>Both work the same when I try them but my try take less writing. Is there something wrong in my try that I don't understand.</p>