In HTML <head> element is the container for all the other HTML element that contain metadata(Data about the data).
Such as:
The <title> element specify the title of the document.
<head>
<title>Title of the document</title>
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title of the page</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
The element provides metadata about the HTML document. It is generally used to describe the page and important keyword in this page. Adding meta description and meta keyword help web browser to search eaisly. Some common use of meta
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 50 seconds:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Students tutorial is a online tutorial for HTML,CSS,PHP.">
<meta name="keywords" content="HTML,CSS,PHP">
<meta name="author" content="John Doe">
</head>
<body>
<p>Page Content goes here.</p>
</body>
</html>
The <style> tag is used to specify style information for a perticular HTML page:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title of the page</title>
<style>
P{
Color: red;
}
</style>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
The <link> element is generally used to load the css file for both internal and external file.
Style.css
P{
Color: red;
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>Hello World!</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="https://studentstutorial.com/style.css">
</head>
<body>
<p>Hello World!</p>
</body>
</html>
The HTML <base> element is used to specify a base URL for all relative links contained in the document, e.g. you can set the base URL once at the top of your page.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<base href="https://www.studentstutorial.com/">
</head>
<body>
<p>Hello World!</p>
</body>
</html>
The <script> element is used to specify client-side script, such as JavaScript in HTML documents.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<script>
document.write("<p>Hello World!</p>")
</script>
</head>
<body>
<p>Script element example</p>
</body>
</html>