19 Aug Why head tag is used in HTML
Whenever an HTML web page is created, adding <head>…</head> is a must, since it is a container. It is placed after the top-most <html> element:
<html> <head> </head> </html>
In the <head>…</head>, add title, CSS styles, scripts, meta, etc, for example:
Title in head element
<html>
<head>
<title>Set Title</title>
</head>
</html>
Meta property in head element
<html>
<head>
<title>Set Title</title>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
</html>
Let us see an example and set head tag in HTML on a web page:
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Document</title>
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h2>Example Heading</h2>
<p>Created a paragraph here.</p>
<p>Sharing is Caring....</p>
</body>
</html>
Output

No Comments