HTML <head> Elements
The <head> section contains metadata and resources that help the browser understand and display the webpage. The content inside the <head> is not shown directly on the page.
Common <head> Elements
-
<title>– Defines the title of the webpage shown in the browser tab. -
<meta>– Provides metadata such as character encoding, description, author, and viewport settings. -
<link>– Links external resources like CSS stylesheets and favicon files. -
<style>– Contains internal CSS styles. -
<script>– Includes or links JavaScript files. -
<base>– Specifies the base URL for all relative URLs in the document.
Example Code
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<style>
body { font-family: Arial, sans-serif; }
</style>
<script>
console.log("Hello, World!");
</script>
<base href="https://example.com/">
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
Summary: The main elements used inside the <head> are <title>, <meta>, <link>, <style>, <script>, and <base>. They provide information about the webpage and load resources needed by the browser.

0 Comments