HTML <head>
View online instance
<title> – defines the title of the HTML document
Use the <title> tag to define the title of the HTML document
<base> – defines the URL for all links
Use <base> to define the default link target address for all links in the page.
<meta> – Provides meta tags for HTML documents
Use the <meta> element to describe the description, keywords, author, character set, etc. of the HTML document.
The HTML <head> Element
The <head> element contains all the head tag elements. In the <head> element you can insert scripts, style files (CSS), and various meta information.
The elements that can be added to the header area are: <title>, <style>, <meta>, <link>, <script>, <noscript> and <base>.
The HTML <title> Element
The <title> tag defines the title of different documents.
<title> is required in HTML/XHTML documents.
The <title> element:
- Defines the title of the browser toolbar
- When a webpage is added to favorites, the title that appears in the favorites
- The title that appears on the search engine results page
A simple HTML document:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Document Title</title>
</head>
<body>
document contents......
</body>
</html>
The HTML <base> Element
The <base> tag describes the base link address/link target, which is used as the default link for all link tags in an HTML document:
<head>
<base href="http://www.it-res.com/images/" target="_blank">
</head>
The HTML <link> Element
The <link> tag defines a relationship between a document and an external resource.
The <link> tag is commonly used to link to a stylesheet:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
The HTML <style> Element
The <style> tag defines the style file reference address of the HTML document.
You can also add styles directly to the rendered HTML document in the <style> element:
<head>
<style type="text/css">
body {
background-color:yellow;
}
p {
color:blue
}
</style>
</head>
The HTML <meta> Element
The meta tag describes some basic metadata.
The <meta> tag provides metadata. Metadata is not displayed on the page, but is parsed by the browser.
The META element is commonly used to specify a web page description, keywords, the time the file was last modified, the author, and other metadata.
Metadata can be used by browsers (how to display the content or reload the page), search engines (keywords), or other web services.
<meta> is usually placed in the <head> area
<meta> Tag – Usage Examples
Define keywords for search engines:
<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript">
Define description content for the web page:
<meta name="description" content="免费 Web & 编程 教程">
Define the page author:
<meta name="author" content="Pa2sw0rd">
Refresh the current page every 30 seconds:
<meta http-equiv="refresh" content="30">
The HTML <script> Element
The <script> tag is used to load script files, such as JavaScript.
The <script> element is described in detail in later chapters.
The HTML head element
Label | describe |
---|---|
<head> | Defines the document information |
<title> | Defines the title of the document |
<base> | Defines the default link address for page link tags |
<link> | Defines the relationship between a document and an external resource |
<meta> | Defines metadata in HTML documents |
<script> | Defines the client script file |
<style> | Defines the style file of the HTML document |
IT Resource Hub » HTML <head>