I would like to go to the DIV of a particular page from a different page. Is that possible?
I tried <a href="file.html#product">Hello</a>
but it just goes to file.html#home
thanks
C.
I have in my file.html but it keeps getting redirected to file.html#home instead.
By prepending your href with # , you can target an HTML element with a specific id attribute. For example, <a href="#footer"> will navigate to the <div id="footer"> within the same HTML document. This type of href is often used to navigate back to the top of the page.
Tip: You can even jump to a section of another web page by specifying the URL of that page along with the anchor (i.e. #elementId ) in the href attribute, for example, <a href="mypage. html#topicA">Go to TopicA</a> .
file.html will need an element with an id="product"
attribute. name
is deprecated for <a>
tags and shouldn't be used.
<div id="product"></div>
With HTML 5, you need to simply add an id
attribute to your <div>
with a value of product
. This needs to be a unique id
attribute within the page (for all elements):
<div id="product">
See the working draft.
In HTML 4.01 you need to use an anchor tag with a name
just above your target div, or any other element with an id
attribute in the other page:
<a name="product"></a>
<div>...
See the HTML 4.01 spec.
Note: The name
attribute has been deprecated in the XHTML 1.0 spec.
So, this would be a better option, as it would work for HTML 4.01, XHTML 1.0 and HTML 5:
<div id="product">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With