<head> element is a container for metadata (data about data) and is placed between the
<html> tag and the
HTML metadata is data about the HTML document. Metadata is not displayed.
Metadata typically define the document title, character set, styles, links, scripts, and other meta information.
The following tags describe metadata:
<title> element defines the title of the document, and is required in all HTML/XHTML documents.
A simple HTML document:
<style> element is used to define style information for a single HTML page:
<link> element is used to link to external style sheets:
Tip: To learn all about CSS, visit our CSS Tutorial.
<meta> element is used to specify which character set is used, page description, keywords, author, and other metadata.
Metadata is used by browsers (how to display content), by search engines (keywords), and other web services.
Define the character set used:
Define a description of your web page:
Define keywords for search engines:
Define the author of a page:
Refresh document every 30 seconds:
HTML5 introduced a method to let web designers take control over the viewport, through the
The viewport is the user's visible area of a web page. It varies with the device, and will be smaller on a mobile phone than on a computer screen.
You should include the following
<meta> viewport element in all your web pages:
<meta> viewport element gives the browser instructions on how to control the page's dimensions and scaling.
The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device).
The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.
Here is an example of a web page without the viewport meta tag, and the same web page with the viewport
Tip: If you are browsing this page with a phone or a tablet, you can click on the two links below to see the difference.
<base> element specifies the base URL and base target for all relative URLs in a page:
According to the HTML5 standard; the
<body>, and the
<head> tag can be omitted.
The following code will validate as HTML5:
W3Schools does not recommend omitting the
<body> tags. Omitting these tags can crash DOM or XML software and produce errors in older browsers (IE9).
However, omitting the
<head> tag has been a common practice for quite some time now.
|<head>||Defines information about the document|
|<title>||Defines the title of a document|
|<base>||Defines a default address or a default target for all links on a page|
|<link>||Defines the relationship between a document and an external resource|
|<meta>||Defines metadata about an HTML document|
|<script>||Defines a client-side script|
|<style>||Defines style information for a document|
For a complete list of all available HTML tags, visit our HTML Tag Reference.