Home > Tips & Tricks > HTML Meta tag to Refresh Page and Redirect

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 😉

Photo of author

About Aman Mehra

Hey there! I'm Aman Mehra, a full-stack developer with over six years of hands-on experience in the industry. I've dedicated myself to mastering the ins and outs of PHP, WordPress, ReactJS, NodeJS, and AWS, so you can trust me to handle your web development needs with expertise and finesse. In 2021, I decided to share my knowledge and insights with the world by starting this blog. It's been an incredible journey so far, and I've had the opportunity to learn and grow alongside my readers. Whether you're a seasoned developer or just dipping your toes into the world of web development, I'm here to provide valuable content and solutions to help you succeed. So, stick around, explore the blog, and feel free to reach out if you have any questions or suggestions. Together, let's navigate the exciting world of web development!

Leave a Comment