Go to div of another page in HTML

I would like to go to the div of a particular page from another page. Is it possible?

I tried <a href="file.html#product">Hello</a>

but it just goes to file.html#home

thanks

FROM.

I have my.html file, but it is redirected to file.html # home instead.

+6
html
source share
3 answers

With HTML 5, you just need to add the id attribute to your <div> with the value product . This should be the unique id attribute on the page (for all elements):

 <div id="product"> 

See working draft .

In HTML 4.01, you need to use the anchor tag with name just above your target div or any other element with the id attribute on another page:

 <a name="product"></a> <div>... 

See HTML 4.01 specification .

Note. The name attribute was deprecated in the XHTML 1.0 specification.

So this will be the best option as it will work for HTML 4.01, XHTML 1.0 and HTML 5:

 <div id="product"> 
+8
source share

file.html will require an element with the id="product" attribute. name deprecated for <a> tags and should not be used.

 <div id="product"></div> 
+8
source share

Do not use binding. This is deprecated. Just give the div id product :

 <div id="product">...</div> 
+4
source share

All Articles