meta http-equiv attribute
The http-equiv attribute on the meta element:
- → represents a pragma directive
- http-equiv is a specific attribute → can be applied ONLY on the next HTML5 element: meta
http-equiv="content-type":
represents a character encoding declaration (a pragma directive)
The MIME type "text/html" is required, followed by a charset: e.g.<meta http-equiv="content-type" content="text/html; charset=utf-8">
http-equiv="default-style":
specifies the preferred stylesheet for the page (a pragma directive)
- example 1: with link element
<meta http-equiv="default-style" content="preferred_style">
where "preferred_style" represents the value of the title attribute of a element (element that links a CSS file to the current page → href attribute required) and that link element is on the same page as the meta element
e.g.
<link rel="stylesheet" type="text/css" href="main.css" title="preferred_style"> - example 2: with style element
<meta http-equiv="default-style" content="preferred_style">
where "preferred_style" represents the value of the title attribute of a element (element that contains CSS rules) and that style element is on the same page as the meta element
e.g.
<style title="preferred_style"> CSS rules here <⁄style>
http-equiv="refresh":
specifies the number of seconds after which the current page/or a new page is reloaded/loaded in the place of the current page (a pragma directive)
- example 1: reload/refresh the current page after 10seconds
<meta http-equiv="refresh" content="10"> - example 2:reload a new page in the place of the current page after 10s
<meta http-equiv="refresh" content="10; url=http://newpage.html/">
Examples
<meta | attribute | = | "value(s)" | > | Examples | ||
---|---|---|---|---|---|---|---|
2. | http-equiv | = | content-type, default-style, refresh | <http-equiv="content-type" content="text/html; charset=UTF-8"> <http-equiv="default-style" content="preferred_style"> <http-equiv="refresh" content="20"> | |||
= | OR register a pragma extension or choose from the preexisting list | <http-equiv="X-UA-Compatible" content="IE=edge"> |
Video demonstration meta http-equiv attribute
HTML5 meta http-equiv attribute Tutorial
min | video details |
---|---|
00:00 | video tutorial: http-equiv on meta element: values content-type and refresh |
00:02 | 4 html pages |
00:05 | loading new pages automatically every 3 seconds |
00:34 | the refresh value of the http-equiv attribute on meta tag allowed us to specify, through the content attribute, the number of seconds after which a new page is loaded in the place of the current page |
00:44 | after 3 seconds page1.html is loaded in the place of the current page, index.html |
00:49 | then, after 3 seconds page2.html is loaded in the place of the page1.html |
00:54 | after 3 seconds page3.html is loaded in the place of the page2.html |
01:00 | and after 3 more seconds we're back to index.html |
01:07 | the http-equiv attribute with a "content-type" value on the meta tag allows us to specify the MIME type and the character encoding set of the document |
01:16 | the http-equiv attribute with a "default-style" value on the meta tag allows us to specify the preferred stylesheet of the document |