HTML : Simplest way to refresh the page in X seconds

Rajesh Kumar Yadav - May 28 '21 - - Dev Community

This is super easy, you just have to put this meta tag inside head tag of your html page.

Without URL

<meta http-equiv="refresh" content="600">
Enter fullscreen mode Exit fullscreen mode

The value in content signifies the seconds after which you want the page to refresh.

<meta http-equiv="refresh" content="0; url=foobar.com/index.html">
Enter fullscreen mode Exit fullscreen mode

Example

The redirects to the provided URL in 5 seconds. Set to 0 for an immediate redirect.

<meta http-equiv="refresh" content="5;url=http://example.com/" />
Enter fullscreen mode Exit fullscreen mode

Bonus

Same thing you can achieve in php as -

<?php
header('Content-Type: text/html; charset=UTF-8');
header('Refresh: 5; url=somewhere/');
?>
Enter fullscreen mode Exit fullscreen mode

Read more

Buy Me A Coffee

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .