HTML Meta Refresh

HTML provides an option to define a time interval to refresh an HTML document itself.

HTML element <meta> with attribute http-equiv="refresh" helps us in defining an auto-refresh time interval as mentioned below.

  • The first example simply refreshes the page every 60 seconds
  • The second example navigates to the specified URL after 60 seconds
<meta http-equiv="refresh" content="60">
<meta http-equiv="refresh" content="60; url=https://randomcodez.com">

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <!-- <meta http-equiv="refresh" content="60"> -->
    <meta http-equiv="refresh" content="60; url=https://randomcodez.com">
</head>
<body>
    <h1>HTML Meta Refresh</h1>
</body>
</html>

Overall

HTML page auto-refresh takes the control of the whole page from the user, so it must be used carefully.