Search code examples
htmlcssreplit

How to link .html files


Alright. I'm coding in HTML and I have gotten stumped on a problem.

I have 3 HTML files:

main.html, buy.html, and CSS.css

and I'm trying to figure out how I can put a link or hyperlink on main.html that redirects me to buy.html.

Edit: Ive been told that buy.html and main.html have to be in the same directory. How do you add the buy.html to the same directory as main.html?

For reference, im using repl.it for coding in HTML


Solution

  • This example will open the linked document in a new browser window/tab:

    <a href="http://www.example.com/" target="_blank" title="Visit My Page">Visit My Page</a>
    

    You can use target="_top" to break out of the frame:

    <a href="http://www.example.com/html/file4.html" target="_top" title="Visit My Page">Visit My Page</a>
    

    Useful Tips Section

    Then, add a link to the bookmark ("Useful Products Section"), from within the same page:

    <a href="#products" title="Visit the Useful products Section">Visit the Useful products Section</a>
    

    Or, add a link to the bookmark ("Useful Tips Section"), from another page: Example

    <a href="file4.html#products" title="Visit the Useful products Section">Visit the Useful products Section</a> 
    

    --

    <a href="page2.html" title="Link">Link</a>
    

    If you have page2.html at the same level with folder then the path is:

    <a href="../page2.html" title="Link">Link</a>