Id and href are stricter in their usage. An id is used to give a unique name to a specific element that can be used in several ways. First thing to note is that only ONE element in an entire HTML page can have a specific id, so this is correct and works:
but this is incorrect:
I believe most browsers usually handle this scenario by only allowing the first id to be valid.
Ids can be used to select a specific element so that you can link to it by making it the href of an
<a> and stating you are using an id by proceeding the name with a #:
<div id="unique"> </div>
<a href="#unique"> link </a>
You can pick any word to use as an id, but the best practice would be to pick something that describes the element and to use ids only when needed. Eg. a class won’t work.
Moving on to the href.
I probably didn’t help much by making the elements in my original post have hrefs of
The href is used to supply a file location to an element such as the
<a>. This can take on the form of a file path:
<a href="./profile_page.html"> Profile </a>
This would link to a html file, named profile_page,
which is located in the folder holding whatever html file
is currently active.
It could also point to a web location:
<a href="https://www.random_web_location.com> random_link </a>
Finally it could point to an element in the current webpage, based on its id:
<div id="element_to_link_to"> <!--content--> </div>
<a href="#element_to_link_to"> link </a>