Hello, welcome to zhullyblog. If this is your first time here , please
Subscribe to Zhullyblog by Email to get latest tutorial.
HTML head element | What is head element and what are the uses.
The head element
<head> is a container that contains all valuable information about the website.
Well, as human beings, our brain is located in the head. The central nervous system consist of the brain and spinal cord right? The brain controls every activities in the body while the spinal cord connects the head to the body. So let's break like this. I said earlier that the brain controls the body right, so the brain which is located in the head element stores information like the
<title> ,
<style> ,
<base> ,
<script> and the spinal cord will be the
<link> that will connect other pages to the main page.
All I am saying is that the
<head> element contain the most important tags in a website.
But what are the elements that should be in the head tag?
The HTML title element
The
<title> element defines the title of the document. The title element is contained in the
<head> element.
The title element is used for the following purpose:
• To display a title in the browser title bar
• To provide a tile for the page when it is bookmarked
• To display title in search engine result.
Here is what I mean
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create a form</title>
</head>
<body>
<h2>Welcome to zhullyblog</h2>
</body>
</html>
The title element is very important. Search engines like google use the tile to index the page.
HTML style element
The
<style> element is used to add CSS to HTML document.
Click here to learn more about CSS style
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create a form</title>
<style>
h2{
color:blue;
}
</style>
</head>
<body>
<h2>Welcome to zhullyblog</h2>
</body>
</html>
The HTML link element
I made a post earlier on links, you can check it out to learn more about links.
The
<link> element give access to view the content in another page. The link element should be inside the head element like this.
Click here to learn more about Links in HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create a form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h2>Welcome to zhullyblog</h2>
</body>
</html>
HTML meta element
The meta element provides the necessary data about the website. It should also be located in the head element.
Click here to learn more about meta tags and it's uses
Here is an example.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create a form</title>
<meta charset="utf-8">
<meta name="author" content="Zhully">
</head>
<body>
<h2>Welcome to zhullyblog</h2>
</body>
</html>
HTML script element
The
<script> element is used to add JavaScript in HTML document. It should also be added to the head element.
Here is an example
<!DOCTYPE html>
<html lang="en">
<head>
<title>Adding JS</title>
<meta charset="utf-8">
<script>
document.write("<h2>Welcome to zhullyblog")
</script>
</head>
<body>
<h2>Welcome to zhullyblog</h2>
</body>
</html>
Please share
Follow us on
Comments
Post a Comment