I’m completely new into coding and so far I have finished some HTML5 basic courses. I then started to create a blog in order to put my knowledge into practice and learn by doing.
In this blog I created a navbar with some links at the top . These links I mentioned later in some of the articles and I was wondering if it’s possible to add an ID to the <a> tag in order to referred it every time I need it, like when referring to a div id with the #, instead of writing the whole path on the href.
I tried it like this, but it doesn’t work
<a href="./aboutme.html" target="_blank" id="aboutme">About me</a> <p>Curious about who is behind this lines? Then check the <a href="#aboutme" target="_blank">"About Me"</a> section. </p>
this is going to append #aboutme to the current url and scroll to the element with that id. If you want to page to jump there this is the way to do it.
Otherwise, add a class to them, add the href with javascript dom
manipulation
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.