| by Arround The Web | No comments

Auto Refresh Code in HTML Using Meta Tags

Auto-refreshing code means executing a service automatically after a specified period of time. When the time defined for auto refresh reaches, it triggers the auto-refresh operation and the code automatically refreshes every time the defined time reaches. A meta tag can be used in HTML to refresh the code according to the defined time period.

How to Auto Refresh Code Using Meta Tags?

To make an auto-refresh using HTML, the meta tag is used with the “http-equiv” property set to “refresh” and then the “content” attribute is used to define the interval of each refresh. To better understand this meta tag, take a look at the syntax below:

Syntax

The syntax to create a meta tag to refresh an HTML code or document is as follows:

<meta http-equiv="refresh" content=" " />

The “http-equiv=refresh” performs the refresh operation and content in this defines the time limit after which the web page automatically refreshes. While refreshing, the content of the web page does not disappear but the tab on which the web page displays keeps on refreshing again and again automatically:

<title>Auto Refresh</title>

<meta http-equiv="refresh" content="5" />

<h2>This will refresh the page after every 5 seconds</h2>

In the above code, we created an HTML meta tag with http-equiv=refresh attribute that gives information about the operation to be performed through this meta tag i.e. refresh, and then added content= attribute and defined its value as 5. This means that the web page that it will create will automatically refresh after 5 minutes and it will continue refreshing after every 5 minutes.

The output created through the above meta tag will keep on refreshing every 5 seconds and will be displayed as:

Note: If we change the value of the content, for instance, if we change it to 15, this will trigger the refresh after every 15 seconds and the web page will refresh after every 15 seconds.

This is how we can auto-refresh an HTML code using Meta tags.

Conclusion

Using Meta tags to auto-refresh an HTML code is very simple. It just requires the http-equiv=refresh attribute to define the refresh operation and the content attribute to define the time period in seconds after which the refresh should be triggered inside the meta tag. The web page automatically keeps on refreshing after every interval of the defined value.

Share Button

Source: linuxhint.com

Leave a Reply