HTML 16 💻 head element
<head> <title>My Page</title> <meta charset=”UTF-8″> <meta name=”description” content=”An example”> <meta name=”keywords” content=”HTML, CSS, JavaScript”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <base href=”https://mydomain.com/” target=”_blank”> <link rel=”stylesheet” href=”styles.css”> <style> body{ background-color: blue; color:white; } </style> <script> alert(“Welcome”) </script> <script src=”scripts.js”></script> </head> <body> <p>Welcome!</p> </body>
If you use the src attribute then you can import a javascript file.
The head element is used to contain metadata and other elements that are not displayed on the web page
Those metadate are important for the proper functioning of the page.
The most common use of the head element is to contain the title of the page
It is displayed at the top of the browser window/tab
head can also contain a meta element to specify the character encoding of the document.
It is important because different documents may use different character sets
meta with description name specifies the page’s description
meta with keywords name specifies keywords for the search engines
meta with viewport name makes your webpage to look nice on all devices
base element defines the base URL for all relative URLs in the webpage
A webpage can only have one base element.
link element with stylesheet rel attribute link to an external CSS/style file
style element gives you the opportunity to style the document using CSS
script element is used to define JavaScript code.