Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to use Meta Tag to redirect an HTML page?
Page redirection is a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.
To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute.
The following is an example of redirecting current page to another page after 2 seconds. If you want to redirect page immediately then do not specify the content attribute or set it to 0.
Syntax
<meta http-equiv="refresh" content="seconds; url=destination-url" />
Parameters
- http-equiv="refresh": Tells the browser this is a refresh instruction
- content: Contains the delay in seconds and the destination URL
- url: The target page to redirect to
Example: Redirect After 2 Seconds
<!DOCTYPE html>
<html>
<head>
<title>HTML Meta Tag Redirect</title>
<meta http-equiv="refresh" content="2; url=https://www.tutorialspoint.com" />
</head>
<body>
<p>This page will redirect to TutorialsPoint in 2 seconds...</p>
</body>
</html>
Example: Immediate Redirect
<!DOCTYPE html>
<html>
<head>
<title>Immediate Redirect</title>
<meta http-equiv="refresh" content="0; url=https://www.example.com" />
</head>
<body>
<p>Redirecting now...</p>
</body>
</html>
Common Use Cases
- Site maintenance: Redirect users to a maintenance page
- URL changes: Automatically redirect from old URLs to new ones
- Mobile detection: Redirect to mobile-optimized versions
- Geographic redirection: Send users to region-specific pages
Key Points
- Meta refresh is processed by the browser, not the server
- Search engines may not follow meta refresh redirects for SEO
- Users can see the original page briefly before redirection
- For SEO purposes, server-side redirects (301/302) are preferred
Conclusion
Meta tag redirects provide a simple HTML-based way to redirect pages after a specified delay. While easy to implement, consider server-side redirects for better SEO performance and user experience.
