Jump to content

a element anchor


jimfog

Recommended Posts

I want to make a link that besides going to a specific page, it must also go to a specific point in that page. How can I do that? In both cases it will be an href attribute, but how am I going to combine these 2 together?

Link to comment
Share on other sites

add a named anchor in that page<a name="point"> on the other page give the acnhor name in link<a href="page.php#point">

Edited by birbal
Link to comment
Share on other sites

There's no name attribute for the <a> element. The #hash part of the URL targets any element that has an ID matching the #hash value.
So you are saying this is the method to follow to achieve what i want.
Link to comment
Share on other sites

Yes! as birbal suggested but using id attribute instead of name attribute. Note, if you link to a point near the of bottom of page, which may contain a few lines of content only, you may get the impression its not working, but remember, it can only only go as far as the very bottom edge of page, and not the norm of showing the point you linked to at the top of page. So it may be better to place larger content, if possible, to point to at bottom of page to avoid this.

Link to comment
Share on other sites

This hash part/id attribute trick...is it brought by HTML5 or is being around even before HTML5? It is the first time i hear of it.

Link to comment
Share on other sites

No, the hash part of the URL's relation to the ID has been standard for a decade at least.
Well, I am surprised to hear that. Then what is the point in using name attributes in the first place?I am talking about the period before HTML5 comes and renders it obsolete.
Link to comment
Share on other sites

The name attribute is more restricted to form input elements, as the name attribute can be used multiple times for radio, checkboxes etc whereas a id reference must be unique within a page. the name attribute was even removed from the form element itself, in preference for a id ref instead.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...