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:
1 2 3 4 5 6 7 |
<html> <head> </head> </html> |
In the <head>…</head>, add title, CSS styles, scripts, meta, etc, for example:
Title in head element
1 2 3 4 5 6 7 |
<html> <head> <title>Set Title</title> </head> </html> |
Meta property in head element
1 2 3 4 5 6 7 8 9 |
<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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<!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