The anchor element in HTML part2


Link to the internal section of a page using the anchor element:

  •  The anchor elements a can be used to create internal links to jump to a different section of the same web page.
  • To create an internal link, you assign links href to a hash symbol plus the value id attribute for the elements that you internally want to link to usually further down the page.
  • then you should add the same id attribute to the element you are linking to.
  • An id is an attribute that uniquely describes an element.
  • The target attribute, in this case, must be not used since this causes the linked document to open into a new page.

<a href="#contacts-header">Contacts</a>
...
<h2 id="contacts-header">Contacts</h2>


  • When the user clicks the contacts link they will be taken to the contacts section of the webpage.



No comments:

Post a Comment