Early Access

Meta Tags

refresh

Learn how to use the refresh meta tag to improve your site.

Used to redirect the user to a new URL after a certain number of seconds, or to refresh the current page. While it can be useful for redirecting users or refreshing content, its usage is generally discouraged in favor of server-side redirects or JavaScript for a better user experience and performance.

Parameters

seconds
The number of seconds to wait before refreshing the page or redirecting.
<meta http-equiv="refresh" content="seconds" />
URL
Optional. The URL to redirect to after the specified number of seconds.
<meta http-equiv="refresh" content="URL" />

Code Examples

<meta http-equiv="refresh" content="5;url=http://example.com" />
Redirects the user to "http://example.com" after 5 seconds, giving a brief moment to read any important information before the redirect.
<meta http-equiv="refresh" content="0;url=http://example.com" />
Immediately redirects the user to "http://example.com", which can be frustrating and confusing, and is potentially harmful for SEO.
<meta http-equiv="refresh" content="300" />
Refreshes the current page every 5 minutes, potentially useful for dashboards displaying periodically updated data.
<meta http-equiv="refresh" content="3" />
Refreshes the page every 3 seconds, likely to annoy users and potentially increase server load unnecessarily.

Recommendations

  • Prefer Server-Side or JavaScript Redirects
    Instead of using meta refresh for redirection, consider server-side HTTP redirects (status code 301 or 302) or JavaScript-based redirection for better SEO and user experience.
  • Use With Caution for Refresh
    If you must use meta refresh for content refresh, keep the interval long enough to not impair the user experience, especially on pages requiring reading or interaction.

Related Documentation

Related Meta Tags

Defines which dynamic resources are allowed to load, thus helping to prevent cross-site scripting attacks, data injection, and other malicious attempts to exploit web page vulnerabilities.

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://apis.google.com;">
Allows scripts, styles, and images to load from the site's own origin and scripts from Google APIs, tightening security by restricting external resources.

content-type

http-equiv

Defines the MIME type and character encoding for the HTML document. It sets the character set used for the HTML document, which is crucial for correctly displaying text.

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
This example specifies the HTML document type with UTF-8 character encoding, ensuring correct text display and maximum compatibility.

default-style

http-equiv

Specifies the name of the preferred stylesheet to use on a web page. This allows users or user agents to choose the default stylesheet amongst many provided.

<meta http-equiv="default-style" content="Main Style">
Correct use case where "Main Style" is precisely the title of one of the page’s alternative stylesheets.

refresh

http-equiv

Used to redirect the user to a new URL after a certain number of seconds, or to refresh the current page. While it can be useful for redirecting users or refreshing content, its usage is generally discouraged in favor of server-side redirects or JavaScript for a better user experience and performance.

<meta http-equiv="refresh" content="5;url=http://example.com">
Redirects the user to "http://example.com" after 5 seconds, giving a brief moment to read any important information before the redirect.

X-UA-Compatible

http-equiv

Advises the web browser to display the webpage in compatibility view or a specific version of Internet Explorer. Primarily used to instruct Internet Explorer to use its Edge rendering engine.

<meta http-equiv="X-UA-Compatible" content="IE=edge">
Instructs Internet Explorer to use the latest available rendering engine, ensuring more modern, standards-compliant HTML & CSS features are used.