Open In App

How to redirect a page to another page in HTML ?

Redirecting a page in HTML involves sending users to a different web page automatically or upon interaction. This is typically achieved using the anchor tag’s href attribute or the meta tag with the HTTP-equiv attribute set to refresh and the content attribute specifying the time delay and destination URL.

Redirect to another page with HTML meta Tag

HTML <meta> tag contains attributes “http-equiv” set to “refresh” and “content” specifying the time delay and the destination URL. Upon page load, the browser reads this meta tag and automatically redirects the user to the specified URL after the specified time delay.

Syntax:



<meta http-equiv = "refresh" content = " time ; url = link"/>

Example: Here is an example of using a meta tag to redirect one page to another page.




<!DOCTYPE html>
<html>
<head>
    <title>Redirecting to Another page in HTML</title>
    <!-- Redirecting to another page using meta tag -->
    <meta http-equiv="refresh"
          content="5; url =https://ide.geeksforgeeks.org" />
</head>
<body>
    <h3>
        Redirecting to Another page in HTML
    </h3>
    <p><strong>Note:</strong> If your browser supports Refresh, you'll be
        redirected to GeeksforGeeks Homepage, in 5 seconds.
    </p>
</body>
</html>

Output:

Redirect to another page with HTML meta Tag example output

Explanation:

Redirect to another page with HTML <a> Tag

Redirecting a page using the anchor tag involves specifying the destination URL in the href attribute. Upon clicking the anchor link, the browser navigates to the provided URL, facilitating seamless page redirection within the web application.

Syntax:

<a href = "link">Link Name </a>

Example: Here we are using anchor tag to redirect our one page to another page.




<!DOCTYPE html>
<html>
<head>
    <title>Redirecting to Another page in HTML</title>
</head>
<body>
    <h3>
        Redirecting to Another page in HTML
    </h3>
    <p>Click the below link to be redirected:
        <a href="https://ide.geeksforgeeks.org" target="_blank">click here</a>
    </p>
</body>
</html>

Output:

Redirect to another page with HTML Tag example output

Explanation:

If you wants to redirect to another page using JavaScript please go through this article: Redirect to another webpage using JavaScript


Article Tags :