Advertisement

Responsive Advertisement

HTML HEAD ELEMENTS

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

  1. <title> – Defines the title of the webpage shown in the browser tab.
  2. <meta> – Provides metadata such as character encoding, description, author, and viewport settings.
  3. <link> – Links external resources like CSS stylesheets and favicon files.
  4. <style> – Contains internal CSS styles.
  5. <script> – Includes or links JavaScript files.
  6. <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.



Post a Comment

0 Comments