HTML CSS examples for HTML Tag:meta
Using the meta Element to Simulate an HTTP Header
You use the http-equiv attribute to specify which header you want to simulate, and the content attribute to provide the value you want to use.
The code sets the refresh header and a value of 5, which asks the browser to reload the page every five seconds.
<!DOCTYPE html> <html> <head> <base href="http://java2s.com"> <meta name="author" content="java2s.com"> <meta name="description" content="A simple example"> <meta charset="utf-8"> <meta http-equiv="refresh" content="5"> </head> <body> <p> I like <code id="myId">HTML</code> and CSS. <!-- w ww.j a v a 2 s. c o m--> </p> <a href="http://java2s.com">Visit java2s.com</a> <a href="page2.html">Page 2</a> </body> </html>
There are three permitted values for the http-equiv attribute listed in the following table.
Attribute Value | Description |
---|---|
refresh | set a period in seconds, after which the current page should reload from the server. You can also specify a different URL to be loaded. For example: <meta http-equiv="refresh" content="5; http://www.java2s.com"/> |
default-style | set the preferred stylesheet that should be used with this page. The value of the content attribute must match the title attribute on a script or link element in the same document. |
content-type | set the character encoding of the HTML page. For example: <meta http-equiv="content-type" content="text/html charset=UTF-8"/> |