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 redirect website after certain amount of time without JavaScript?
To redirect from an HTML page without JavaScript, use the META tag with the http-equiv="refresh" attribute. This provides an HTTP header that tells the browser to automatically redirect after a specified number of seconds.
Through this method, you can automatically redirect your visitors to a new homepage or any other page. Set the content attribute to 0 if you want the redirect to happen immediately.
Syntax
<meta http-equiv="refresh" content="seconds; url=destination_url" />
Parameters
The content attribute contains two parts separated by a semicolon:
- seconds - Number of seconds to wait before redirecting
- url - The destination URL to redirect to
Example: Redirect After 2 Seconds
The following example redirects the current page to TutorialsPoint after 2 seconds:
<!DOCTYPE html>
<html>
<head>
<title>Redirection Example</title>
<meta http-equiv="refresh" content="2; url=https://www.tutorialspoint.com" />
</head>
<body>
<h1>Page Redirection</h1>
<p>This page will redirect to TutorialsPoint in 2 seconds...</p>
</body>
</html>
Example: Immediate Redirect
For instant redirection, set the time to 0 seconds:
<!DOCTYPE html>
<html>
<head>
<title>Immediate Redirect</title>
<meta http-equiv="refresh" content="0; url=/home" />
</head>
<body>
<p>Redirecting immediately...</p>
</body>
</html>
Example: Refresh Current Page
To refresh the same page without redirecting to a different URL, omit the URL parameter:
<!DOCTYPE html>
<html>
<head>
<title>Auto Refresh</title>
<meta http-equiv="refresh" content="5" />
</head>
<body>
<h1>Current Time</h1>
<p>This page refreshes every 5 seconds to show updated content.</p>
</body>
</html>
Common Use Cases
- Website maintenance - Redirect users from old pages to new ones
- Temporary pages - Show a message and redirect after reading
- Auto-refresh - Keep content updated without user interaction
- Fallback redirection - When JavaScript is disabled
Browser Compatibility
The meta refresh tag is supported by all modern browsers and has been part of HTML standards for decades. It works regardless of JavaScript being enabled or disabled.
Conclusion
The HTML meta refresh tag provides a simple, JavaScript-free way to redirect pages or refresh content automatically. Use it for basic redirections when you need broad browser compatibility.
