HTML Header Elements

More examples

Document title
The <title> tag defines the title of the document.
All links have a target
How to use the base tag to open all tags in a new window on the page.
Document description
Use the <meta> element to describe the document.
Document keywords
Use the <meta> element to define the keywords of the document.
Redirect users
How to redirect users to a new URL.

HTML <head> element

The <head> element is the container for all head elements. Elements within <head> can include scripts, indicate where the browser can find style sheets, provide meta-information, and so on.

The following tags can be added to the head section: <title>, <base>, <link>, <meta>, <script>, and <style>.

HTML <title> element

The <title> tag defines the title of the document.

The title element is required in all HTML/XHTML documents.

The title element can:

  • Title defined in the browser toolbar
  • Title displayed when the page is added to favorites
  • Page title displayed in search engine results

A simplified HTML document:

<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>

HTML <base> element

The <base> tag specifies the default address or default target (target) for all links on the page:

<head>
<base href="http://www.codew3c.com/images/" />
<base target="_blank" />
</head>

HTML <link> element

The <link> tag defines the relationship between the document and external resources.

The <link> tag is most commonly used to link style sheets:

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>

HTML <style> element

The <style> tag is used to define style information for HTML documents.

You can specify the style of HTML elements in the browser within the style element:

<head>
<style type="text/css">
body {background-color:yellow}
p {color:blue}
</style>
</head>

HTML <meta> element

Metadata (metadata) is information about data.

The <meta> tag provides metadata about the HTML document. Metadata is not displayed on the page, but is readable by machines.

Typically, the meta element is used to specify the page description, keywords, the author of the document, the last modified time, and other metadata.

The <meta> tag is always located within the head element.

Metadata can be used by browsers (how content is displayed or pages are reloaded), search engines (keywords), or other web services.

Keywords for search engines

Some search engines will use the name and content attributes of the meta element to index your page.

The following meta element defines the description of the page:

<meta name="description" content="Free Web tutorials on HTML, CSS, XML" />

The following meta element defines the keywords of the page:

<meta name="keywords" content="HTML, CSS, XML" />

The name and content attributes of the meta tag are used to describe the content of the page.

HTML <script> Element

The <script> tag is used to define client-side scripts, such as JavaScript.

We will explain the script element in a later chapter.

HTML Header Elements

Tag Description
<head> Define information about the document.
<title> Define the document title.
<base> Define the default address or default target for all links on the page.
<link> Define the relationship between the document and external resources.
<meta> Define metadata about the HTML document.
<script> Define client-side scripts.
<style> Define the style information of the document.