Home > Enterprise >  How to make a link from one HTML document to another HTML document and also includes a quick link?
How to make a link from one HTML document to another HTML document and also includes a quick link?

Time:03-22

I would like to link from one page to the other. But it should also be scrolled down after I came to the other document. I don't know if you can do that with this code... I know that you can use it to link to other sites and also make quick links, but is that also possible at the same time? also looked at some other posts, but they are too complex for my brain. xD

LG JJ

<a name="anker" href="#anker"></a>

CodePudding user response:

Yes, you can link to an item from another file using /file#id adress. Take a look at this example.

Inside file1.html:

<h1>This is file 1</h1>
<a href="file2.html#item">Link</a>

Inside file2.html:

<h1>This is file 2</h1>
<div>
    Something
</div>
<p id="item">Hello</p>

for smooth scrolling effect use

html{
    scroll-behavior: smooth;
}

and link this to file2.html.

  • Related