The HTML header is used to define the head portion of the HTML document which contains information related to the document. It is placed between <html> tag and the <body> tag.
The <head> tag specifies header of the document.
The HTML header section is a part whose content is not displayed on the webpage on page loading.
HTML header contains metadata about the HTML document which specifies data about the HTML document.
An HTML document contains a <title> tag, <meta> tags, a <script> tag and a <style> tag, all these elements are enclosed in the <head> element.
Following tags are used in metadata:
<title>
<style>
<meta>
<link>
<script>
<base>
HTML <title> Element:
The title tag is used to declare the title or name of the HTML document. The title written inside <title>…</title> is displayed in browser’s title bar. It is also displayed in the bookmarks and search results.
Example:
<!DOCTYPE html>
<html>
<head>
<title> Title of page </title>
</head>
<body>
<p>The content written inside body element is displayed in the browser window.</p>
<p>The content written inside title element is displayed in the browser tab, in favorites and in search engine results.</p>
An HTML <style> element is used to style the HTML page. The <style> element have CSS properties for that page only. If you want to apply CSS for multiple pages then you should use the separate CSS file.
The <link> element in HTML is used to link an external stylesheet to your webpage.
The <link> element has two main attributes which are “rel” and “href”. The “rel” indicates specifies the relationship between two linked documents and “href” specifies the path to that external file.
The HTML <meta> element is used to define the character set, page description, keywords, authors and other metadata on the webpage.
Metadata is used by browsers, search engines, and other web services to rank your webpage better.
Let's see how to use metadata:
To define a character set:
The attribute charset = utf-8 is character encoding capable of encoding all characters on the web.
<meta charset="UTF-8">
To define a description of your webpage:
The meta description is used for the relevant search, performed by search engines.
The viewport is the area of the web page that is visible to the user. The viewport does not have the same size, its size varies with the variation in screen size. HTML5 introduced a method to take control of the viewport by using <meta> tag.
<p>
HTML is a markup language using which you can create your website.
HTML stands for Hypertext Markup Language.
It contains elements and the elements are represented by tags. </p>
<p>
HTML is a markup language using which you can create your website.
HTML stands for Hypertext Markup Language.
It contains elements and the elements are represented by tags. </p>
Note: It is not recommended to exclude the <html> and <body> tags. Excluding these tags can crash DOM or XML software and produce errors in older browsers (IE9).
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok