What Is HTML?: Example
What Is HTML?: Example
HTML Introduction
What is HTML?
HTML is the standard markup language for creating Web pages.
HTML stands for Hyper Text Markup Language
HTML describes the structure of Web pages using markup
HTML elements are the building blocks of HTML pages
HTML elements are represented by tags
HTML tags label pieces of content such as "heading", "paragraph",
"table", and so on
Browsers do not display the HTML tags, but use them to render
the content of the page
</body>
</html>
Try it Yourself »
Example Explained
The <!DOCTYPE html> declaration defines this document to be
HTML5
The <html> element is the root element of an HTML page
The <head> element contains meta information about the
document
The <title> element specifies a title for the document
The <body> element contains the visible page content
The <h1> element defines a large heading
The <p> element defines a paragraph
HTML Tags
HTML tags are element names surrounded by angle brackets:
Tip: The start tag is also called the opening tag, and the end tag the
closing tag.
Web Browsers
The purpose of a web browser (Chrome, IE, Firefox, Safari) is to read
HTML documents and display them.The browser does not display the
HTML tags, but uses them to determine how to display the document:
HTML Page Structure
Below is a visualization of an HTML page structure:
<html>
<head>
<title>Page title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</html>
Note: Only the content inside the <body> section (the white area
above) is displayed in a browser.
It must only appear once, at the top of the page (before any HTML
tags).
<!DOCTYPE html>
HTML Versions
Since the early days of the web, there have been many versions of
HTML:
Version Year
HTML 1991
XHTML 2000
HTML5 2014
HTML Editors
Follow the four steps below to create your first web page with Notepad
or TextEdit.
Open the Start Screen (the window symbol at the bottom left on your
screen). Type Notepad.
Windows 7 or earlier:
Then under "Open and Save", check the box that says "Ignore rich text
commands in HTML files".
<!DOCTYPE html>
<html>
<body>
Text Formatting
This text is bold
Try it Yourself »
HTML also defines special elements for defining text with a special
meaning.
HTML uses elements like <b> and <i> for formatting output, like bold
or italic text.
Formatting elements were designed to display special types of text:
Example
<b>This text is bold</b>
Try it Yourself »
The HTML <strong> element defines strong text, with added semantic
"strong" importance.
Example
<strong>This text is strong</strong>
Try it Yourself »
Example
<i>This text is italic</i>
Try it Yourself »
The HTML <em> element defines emphasized text, with added semantic
importance.
Example
<em>This text is emphasized</em>
Try it Yourself »
Example
<h2>HTML <small>Small</small> Formatting</h2>
Try it Yourself »
Example
<h2>HTML <mark>Marked</mark> Formatting</h2>
Try it Yourself »
Example
<p>My favorite color is <del>blue</del> red.</p>
Try it Yourself »
Example
<p>My favorite <ins>color</ins> is red.</p>
Try it Yourself »
Example
<p>This is <sub>subscripted</sub> text.</p>
Try it Yourself »
Example
<p>This is <sup>superscripted</sup> text.</p>
Try it Yourself »
HTML Lists
An Ordered List:
1. First item
2. Second item
3. Third item
4. Fourth item
The list items will be marked with bullets (small black circles) by
default:
Example
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Try it Yourself »
Value Description
disc Sets the list item marker to a bullet (default)
Example - Disc
<ul style="list-style-type:disc">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Try it Yourself »
Example - Circle
<ul style="list-style-type:circle">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Try it Yourself »
Example - Square
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Try it Yourself »
Example - None
<ul style="list-style-type:none">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Try it Yourself »
Example
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Try it Yourself »
Type Description
Numbers:
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Try it Yourself »
Uppercase Letters:
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Try it Yourself »
Lowercase Letters:
<ol type="a">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Try it Yourself »
Uppercase Roman Numbers:
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
Try it Yourself »
The <dl> tag defines the description list, the <dt> tag defines the term
(name), and the <dd> tag describes each term:
Example
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Try it Yourself »
Try it Yourself »
Note: List items can contain new list, and other HTML elements, like
images and links, etc.
Chapter Summary
Use the HTML <ul> element to define an unordered list
Use the CSS list-style-type property to define the list item marker
Use the HTML <ol> element to define an ordered list
Use the HTML type attribute to define the numbering type
Use the HTML <li> element to define a list item
Use the HTML <dl> element to define a description list
Use the HTML <dt> element to define the description term
Use the HTML <dd> element to describe the term in a description
list
Lists can be nested inside lists
List items can contain other HTML elements
Use the CSS property float:left or display:inline to display a list
horizontally
HTML Links
Links are found in nearly all web pages. Links allow users to click
their way from page to page.
When you move the mouse over a link, the mouse arrow will turn into a
little hand.
Note: A link does not have to be text. It can be an image or any other
HTML element.
Example
<a href="https://www.w3schools.com/html/">Visit our HTML tutorial</a>
Try it Yourself »
The link text is the visible part (Visit our HTML tutorial).
Clicking on the link text will send you to the specified address.
A local link (link to the same web site) is specified with a relative URL
(without http://www....).
Example
<a href="html_images.asp">HTML Images</a>
Try it Yourself »
Example
< style>
a:link {
color: green;
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
Try it Yourself »
Example
<a href="https://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
Try it Yourself »
Example
<a href="https://www.w3schools.com/html/" target="_top">HTML5 tutorial!</a>
Try it Yourself »
Try it Yourself »
To make a bookmark, you must first create the bookmark, and then add
a link to it.
When the link is clicked, the page will scroll to the location with the
bookmark.
Example
First, create a bookmark with the id attribute:
Then, add a link to the bookmark ("Jump to Chapter 4"), from within
the same page:
Or, add a link to the bookmark ("Jump to Chapter 4"), from another
page:
Example
<a href="html_demo.html#C4">Jump to Chapter 4</a>
Try it Yourself »
External Paths
External pages can be referenced with a full URL or with a path relative
to the current web page.
Example
<a href="https://www.w3schools.com/html/default.asp">HTML tutorial</a>
Try it Yourself »
This example links to a page located in the html folder on the current
web site:
Example
<a href="/html/default.asp">HTML tutorial</a>
Try it Yourself »
This example links to a page located in the same folder as the current
page:
Example
<a href="default.asp">HTML tutorial</a>
Try it Yourself »
You can read more about file paths in the chapter HTML File Paths.
Chapter Summary
Use the <a> element to define a link
Use the href attribute to define the link address
Use the target attribute to define where to open the linked
document
Use the <img> element (inside <a>) to use an image as a link
Use the id attribute (id="value") to define bookmarks in a page
Use the href attribute (href="#value") to link to the bookmark
HTML Images
JPG Images
GIF Images
PNG Images
Example
<!DOCTYPE html>
<html>
<body>
<h2>Spectacular Mountain</h2>
<img src="pic_mountain.jpg" alt="Mountain View"
style="width:304px;height:228px;">
</body>
</html>
Try it Yourself »
The <img> tag is empty, it contains attributes only, and does not have
a closing tag.
The src attribute specifies the URL (web address) of the image:
If a browser cannot find an image, it will display the value of the alt
attribute:
Example
<img src="wrongname.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
Try it Yourself »
The alt attribute is required. A web page will not validate correctly
without it.
Example
<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">
Try it Yourself »
Alternatively, you can use the width and height attributes. Here, the
values are specified in pixels by default:
Example
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
Try it Yourself »
Note: Always specify the width and height of an image. If width and
height are not specified, the page will flicker while the image loads.
Example
<!DOCTYPE html>
<html>
<head>
<style>
img {
width:100%;
}
</style>
</head>
<body>
</body>
</html>
Try it Yourself »
Example
<img src="/images/html5.gif" alt="HTML5 Icon"
style="width:128px;height:128px;">
Try it Yourself »
Actually, you can access images from any web address in the world:
Example
<img src="https://www.w3schools.com/images/w3schools_green.jpg"
alt="W3Schools.com">
Try it Yourself »
You can read more about file paths in the chapter HTML File Paths.
Animated Images
The GIF standard allows animated images:
Example
<img src="programming.gif" alt="Computer Man"
style="width:48px;height:48px;">
Try it Yourself »
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial"
style="width:42px;height:42px;border:0;">
</a>
Try it Yourself »
Image Floating
Use the CSS float property to let the image float to the right or to the
left of a text:
Example
<p><img src="smiley.gif" alt="Smiley face"
style="float:right;width:42px;height:42px;">
The image will float to the right of the text.</p>
Try it Yourself »
Image Maps
Use the <map> tag to define an image-map. An image-map is an image
with clickable areas.
The name attribute of the <map> tag is associated with the <img>'s
usemap attribute and creates a relationship between the image and the
map.
The <map> tag contains a number of <area> tags, that defines the
clickable areas in the image-map:
Example
<img src="planets.gif" alt="Planets" usemap="#planetmap"
style="width:145px;height:126px;">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
Try it Yourself »
Chapter Summary
Use the HTML <img> element to define an image
Use the HTML src attribute to define the URL of the image
Use the HTML alt attribute to define an alternate text for an
image, if it cannot be displayed
Use the HTML width and height attributes to define the size of the
image
Use the CSS width and height properties to define the size of the
image (alternatively)
Use the CSS float property to let the image float
Use the HTML <map> element to define an image-map
Use the HTML <area> element to define the clickable areas in the
image-map
Use the HTML <img>'s element usemap attribute to point to an
image-map
Note: Loading images takes time. Large images can slow down your
page. Use images carefully.
HTML Tables
Each table row is defined with the <tr> tag. A table header is defined
with the <th> tag. By default, table headings are bold and centered. A
table data/cell is defined with the <td> tag.
Example
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Try it Yourself »
Note: The <td> elements are the data containers of the table.
They can contain all sorts of HTML elements; text, images, lists, other
tables, etc.
Example
table, th, td {
border: 1px solid black;
}
Try it Yourself »
Remember to define borders for both the table and the table cells.
If you do not specify a padding, the table cells will be displayed without
padding.
Example
th, td {
padding: 15px;
}
Try it Yourself »
Example
th {
text-align: left;
}
Try it Yourself »
HTML Table - Adding Border Spacing
Border spacing specifies the space between the cells.
To set the border spacing for a table, use the CSS border-spacing
property:
Example
table {
border-spacing: 5px;
}
Try it Yourself »
Example
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
Try it Yourself »
Try it Yourself »
Example
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
Try it Yourself »
Note: The <caption> tag must be inserted immediately after the
<table> tag.
Example
<table id="t01">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Try it Yourself »
Try it Yourself »
Chapter Summary
Use the HTML <table> element to define a table
Use the HTML <tr> element to define a table row
Use the HTML <td> element to define a table data
Use the HTML <th> element to define a table heading
Use the HTML <caption> element to define a table caption
Use the CSS border property to define a border
Use the CSS border-collapse property to collapse cell borders
Use the CSS padding property to add padding to cells
Use the CSS text-align property to align cell text
Use the CSS border-spacing property to set the spacing between
cells
Use the colspan attribute to make a cell span many columns
Use the rowspan attribute to make a cell span many rows
Use the id attribute to uniquely define one table
HTML Forms
Last name:
Try it Yourself »
<form>
.
form elements
.
</form>
Form elements are different types of input elements, like text fields,
checkboxes, radio buttons, submit buttons, and more.
Type Description
Example
<form>
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
</form>
Try it Yourself »
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a
text field is 20 characters.
Example
<form>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
</form>
Try it Yourself »
Example
<form action="/action_page.php">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
Try it Yourself »
First name:
Last name:
Normally, the form data is sent to a web page on the server when the
user clicks on the submit button.
In the example above, the form data is sent to a page on the server
called "/action_page.php". This page contains a server-side script that
handles the form data:
<form action="/action_page.php">
If the action attribute is omitted, the action is set to the current page.
or:
However, when GET is used, the submitted form data will be visible in
the page address field:
/action_page.php?firstname=Mickey&lastname=Mouse
Note: GET must NOT be used when sending sensitive information! GET
is best suited for short, non-sensitive, amounts of data, because it has
size limitations too.
If the name attribute is omitted, the data of that input field will not be
sent at all.
This example will only submit the "Last name" input field:
Example
<form action="/action_page.php">
First name:<br>
<input type="text" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
Try it Yourself »
Example
<form action="/action_page.php">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
Try it Yourself »
Last name:
from a form.
HTML – Frames
HTML frames are used to divide your browser window into multiple sections
where each section can load a separate HTML document. A collection of frames
in the browser window is known as a frameset. The window is divided into
frames in a similar way the tables are organized: into rows and columns.
Disadvantages of Frames
There are few drawbacks with using frames, so it's never recommended to use
frames in your webpages −
Some smaller devices cannot cope with frames often because their screen
is not big enough to be divided up.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body> tag. The
<frameset> tag defines, how to divide the window into frames. The rows
attribute of <frameset> tag defines horizontal frames and cols attribute
defines vertical frames. Each frame is indicated by <frame> tag and it defines
which HTML document shall open into the frame.
Example
Following is the example to create three horizontal frames −
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
This will produce the following result −
Example
Let's put the above example as follows, here we replaced rows attribute by cols
and changed their width. This will create all the three frames vertically −
<!DOCTYPE html>
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
1 cols
Specifies how many columns are contained in the frameset and the size of each column. You can
specify the width of each column in one of the four ways −
Absolute values in pixels. For example, to create three vertical frames, use cols = "100, 500, 100".
A percentage of the browser window. For example, to create three vertical frames, use cols = "10%,
80%, 10%".
Using a wildcard symbol. For example, to create three vertical frames, use cols = "10%, *, 10%".
In this case wildcard takes remainder of the window.
As relative widths of the browser window. For example, to create three vertical frames, use cols =
"3*, 2*, 1*". This is an alternative to percentages. You can use relative widths of the browser
window. Here the window is divided into sixths: the first column takes up half of the window, the
second takes one third, and the third takes one sixth.
rows
This attribute works just like the cols attribute and takes the same values, but it is used to specify
2
the rows in the frameset. For example, to create two horizontal frames, use rows = "10%, 90%".
You can specify the height of each row in the same way as explained above for columns.
border
3 This attribute specifies the width of the border of each frame in pixels. For example, border = "5".
A value of zero means no border.
frameborder
This attribute specifies whether a three-dimensional border should be displayed between frames.
4
This attribute takes value either 1 (yes) or 0 (no). For example frameborder = "0" specifies no
border.
framespacing
This attribute specifies the amount of space between frames in a frameset. This can take any
5
integer value. For example framespacing = "10" means there should be 10 pixels spacing between
each frames.
The <frame> Tag Attributes
Following are the important attributes of <frame> tag −
src
1 This attribute is used to give the file name that should be loaded in the frame. Its value can be any
URL. For example, src = "/html/top_frame.htm" will load an HTML file available in html
directory.
name
This attribute allows you to give a name to a frame. It is used to indicate which frame a document
2 should be loaded into. This is especially important when you want to create links in one frame that
load pages into an another frame, in which case the second frame needs a name to identify itself
as the target of the link.
frameborder
This attribute specifies whether or not the borders of that frame are shown; it overrides the value
3
given in the frameborder attribute on the <frameset> tag if one is given, and this can take values
either 1 (yes) or 0 (no).
marginwidth
4 This attribute allows you to specify the width of the space between the left and right of the frame's
borders and the frame's content. The value is given in pixels. For example marginwidth = "10".
marginheight
5 This attribute allows you to specify the height of the space between the top and bottom of the
frame's borders and its contents. The value is given in pixels. For example marginheight = "10".
6 noresize
By default, you can resize any frame by clicking and dragging on the borders of a frame. The
noresize attribute prevents a user from being able to resize the frame. For example noresize =
"noresize".
scrolling
7 This attribute controls the appearance of the scrollbars that appear on the frame. This takes values
either "yes", "no" or "auto". For example scrolling = "no" means it should not have scroll bars.
longdesc
This attribute allows you to provide a link to another page containing a long description of the
8 contents of the frame. For example longdesc = "framedescription.htm"
So you must place a <body> element inside the <noframes> element because
the <frameset> element is supposed to replace the <body> element, but if a
browser does not understand <frameset> element then it should understand
what is inside the <body> element which is contained in a <noframes>
element.
You can put some nice message for your user having old browsers. For
example, Sorry!! your browser does not support frames. as shown in the above
example.
Let's see following example where a test.htm file has following code −
<!DOCTYPE html>
<html>
<head>
<title>HTML Target Frames</title>
</head>
<noframes>
<body>Your browser does not support frames.</body>
</noframes>
</frameset>
</html>
Here, we have created two columns to fill with two frames. The first frame is
200 pixels wide and will contain the navigation menu bar implemented by
menu.htm file. The second column fills in remaining space and will contain the
main part of the page and it is implemented by main.htm file. For all the three
links available in menu bar, we have mentioned target frame as main_page, so
whenever you click any of the links in menu bar, available link will open in main
page.
<!DOCTYPE html>
<html>
</html>
<!DOCTYPE html>
<html>
</html>
Now you can try to click links available in the left panel and see the result. The
targetattribute can also take one of the following values −
_self
1
Loads the page into the current frame.
_blank
2
Loads a page into a new browser window. Opening a new window.
3 _parent
Loads the page into the parent window, which in the case of a single frameset is the main browser
window.
_top
4
Loads the page into the browser window, replacing any current frames.
targetframe
5
Loads the page into a named targetframe.
The <meta> tag is used to provide such additional information. This tag is an
empty element and so does not have a closing tag but it carries information
within its attributes.
You can include one or more meta tags in your document based on what
information you want to keep in your document but in general, meta tags do
not impact physical appearance of the document so from appearance point of
view, it does not matter if you include them or not.
Adding Meta Tags to Your Documents
You can add metadata to your web pages by placing <meta> tags inside the
header of the document which is represented by <head> and </head> tags. A
meta tag can have following attributes in addition to core attributes −
Name
1
Name for the property. Can be anything. Examples include, keywords, description, author,
revised, generator etc.
content
2
Specifies the property's value.
scheme
3
Specifies a scheme to interpret the property's value (as declared in the content attribute).
http-equiv
4 Used for http response message headers. For example, http-equiv can be used to refresh the page
or to set a cookie. Values include content-type, expires, refresh and set-cookie.
Specifying Keywords
You can use <meta> tag to specify important keywords related to the
document and later these keywords are used by the search engines while
indexing your webpage for searching purpose.
Example
Following is an example, where we are adding HTML, Meta Tags, Metadata as
important keywords about the document.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Document Description
You can use <meta> tag to give a short description about the document. This
again can be used by various search engines while indexing your webpage for
searching purpose.
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "revised" content = "Tutorialspoint, 3/7/2014" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Document Refreshing
A <meta> tag can be used to specify a duration after which your web page will
keep refreshing automatically.
Example
If you want your page keep refreshing after every 5 seconds then use the
following syntax.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "revised" content = "Tutorialspoint, 3/7/2014" />
<meta http-equiv = "refresh" content = "5" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Page Redirection
You can use <meta> tag to redirect your page to any other webpage. You can
also specify a duration if you want to redirect the page after a certain number
of seconds.
Example
Following is an example of redirecting current page to another page after 5
seconds. If you want to redirect page immediately then do not specify content
attribute.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "revised" content = "Tutorialspoint, 3/7/2014" />
<meta http-equiv = "refresh" content = "5; url = http://www.tutorialspoint.com"
/>
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Setting Cookies
Cookies are data, stored in small text files on your computer and it is exchanged
between web browser and web server to keep track of various information
based on your web application need.
You can use <meta> tag to store cookies on client side and later this
information can be used by the Web Server to track a site visitor.
Example
Following is an example of redirecting current page to another page after 5
seconds. If you want to redirect page immediately then do not specify content
attribute.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "revised" content = "Tutorialspoint, 3/7/2014" />
<meta http-equiv = "cookie" content = "userid = xyz;
expires = Wednesday, 08-Aug-15 23:59:59 GMT;" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
If you do not include the expiration date and time, the cookie is considered a
session cookie and will be deleted when the user exits the browser.
Note − You can check PHP and Cookies tutorial for a complete detail on Cookies.
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "author" content = "Mahnaz Mohtashim" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
By default, Web servers and Web browsers use ISO-8859-1 (Latin1) encoding
to process Web pages. Following is an example to set UTF-8 encoding −
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "author" content = "Mahnaz Mohtashim" />
<meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
To serve the static page with traditional Chinese characters, the webpage must
contain a <meta> tag to set Big5 encoding −
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content = "HTML, Meta Tags, Metadata" />
<meta name = "description" content = "Learning about Meta Tags." />
<meta name = "author" content = "Mahnaz Mohtashim" />
<meta http-equiv = "Content-Type" content = "text/html; charset = Big5" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>