I`ve seen on various websites, some links appear like this: http://www.myserver.com/page.html#something and when I click on it, it just moves to another portion of the page.
I want to know how to do this. Is it only the URL of the <a href> atrribute?
The fragment at the end of the url coresponds to an ID on the page you’re visiting.
If in my page I have a section such as:
Then I can take the user to this section by attaching
#commentsto the pages URL(http://www.example.com/page.html#comments)
Update
Some of the other answers here correctly point out that you can create an anchor with a name attribute as:
<a name="example"></a>.Although this is technically correct, it’s also a very antiquated way of doing things and something I’d recommend you avoid. It’s very 1997 as some might say 🙂