The <head> element is a container for meta data (data about data).
HTML meta data is data about the HTML document. Metadata is not displayed.
Meta data typically define document title, styles, links, scripts, and other meta information.
The following tags describes meta data: <title>, <style>, <meta>, <link>, <script>, and <base>.
In the HTML5 standard, the <html> tag, the <body> tag, and the <head> tag can be omitted.
The following code will validate as HTML5:
W3Schools does not recommend omitting the <html> and <body> tags: |
The <html> element is the document root. It is the recommended place for specifying the page language:
Declaring a language is important for accessibility applications (screen readers) and search engines.
Omitting <html> and <body> can crash badly written DOM and XML software.
Finally, omitting <body> can produce errors in older browsers (IE9).
In the HTML5 standard, the <head> tag can also be omitted.
By default, browsers will add all elements before <body>, to a default <head> element.
You can reduce the complexity of HTML, by omitting the <head> tag:
Omitting tags is unfamiliar to web developers. It needs time to be established as a
guideline. |
The <title> element defines the title of the document.
The <title> element is required in all HTML/XHTML documents.
The <title> element:
A simplified HTML document:
The <style> element is used to define style information for an HTML document.
Inside the <style> element you specify how HTML elements should render in a browser:
The <link> element defines the page relationship to an external resource.
The <link> element is most often used to link to style sheets:
The <meta> element is used to specify page description, keywords, author, and other metadata.
Meta data is used by browsers (how to display content), by search engines (keywords), and other web services.
Define keywords for search engines:
Define a description of your web page:
Define the character set used:
Define the author of a page:
Refresh document every 30 seconds:
The <script> element is used to define client-side JavaScripts.
The script below writes Hello JavaScript! into an HTML element with id="demo":
To learn all about JavaScript, visit our JavaScript Tutorial! |
The <base> element specifies the base URL and base target for all relative URLs in a page:
Tag | Description |
---|---|
<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 |