Vibes

Need to link it?

While working on my website, I took a closer look at the anchor element and the href attribute. I ended up revisiting a few things I needed a refresher on, so I thought I’d share it with you.

href="" reloads the current page, keeps the search string, but drops the hash if you have one.

href="." also reloads the page, but wipes out both the search string and the hash.

href="#" scrolls straight to the top of the page. href="#top" does the same—unless there’s actually an element with the id “top”. Bonus tip, you can even use something like href="#page=3" to jump to page three in a PDF.

Hopefully this helps make the world of links a little less mysterious and saves you a few “wait, what just happened?” moments.