HTML Meta tag to Refresh Page and Redirect

Hi Friends, in this trick, you will learn how to refresh or redirect a page using the HTML meta tag. You may have used the javascript function window.reload() but do you know HTML also has a built-in tag for this?

The page refresh means the browser will load the whole page again, and if you want the page automatically refresh after a specific time then this trick is for you.

And the page redirect means the browser will redirect you from one page URL to another page URL or a different website, and you can also do this with a time range with this trick.

Let’s see how to refresh and redirect the page using the HTML tag.

Refresh Page with HTML Tag

To refresh the whole page with an HTML tag, you have to add a <meta> tag with set interval time inside your document’s <head> section. See the following line of code for reference.

In the above line of code, the value http-equiv attribute of the meta tag should be “refresh” and for content attribute value should be in seconds.

So the above line of code will refresh the page after 30 seconds. You can set intervals in seconds and as per requirements.

Redirect Page with HTML Tag

To redirect the page to another page or another website, you have to add the same above <meta> tag with the attributes of http-equiv and content. But little change in a content attribute adding a second parameter with separating by ;. See the following line of code.

In the above line of code, we added the http-equiv and content attributes. And we set the interval time to 30 seconds for the content attribute and along with that, we added the second parameter of the website URL where we want to redirect after that specific time.

So, it will redirect the page after 30 seconds to another website (https://www.google.com). So thus, you can use the special HTML meta tag to refresh the page and redirect to another website.

Being Tricky 😉

Leave a Reply

Your email address will not be published.