logo Learn HTML
  • Home
  • Tutorials
  • Practice
  • Quiz
  • Projects
  • About
  • Contact

HTML Course

  • HTML HOME
  • HTML Introduction
  • HTML Basic
  • HTML Element
  • HTML Attributes
  • HTML Headings
  • HTML Paragrapha
  • HTML Style
  • HTML Formattin
  • HTML Quotations
  • HTML Colors
  • HTML Css
  • HTML Links
  • HTML Image
  • HTML Favicon
  • Page Tittle
  • HTML Tables
  • HTML Lists
  • Block & Inline
  • HTML Div
  • HTML Classes
  • HTML Id
  • HTML Buttons
  • HTML Iframes
  • HTML File Paths
  • HTML Head
  • HTML Layout
  • HTML Symbols
  • HTML Emojis
  • HTML URL Encode
  • HTML VS XHTML
  • HTML FROM
  • HTML Form
  • Form Attributes
  • Form Elements
  • HTML Input Types
  • HTML Input Attributes
  • Input Form Attributes
  • HTML Graphics
  • HTML Canvas
  • HTML SVG
  • HTML Media
  • HTML Media
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML Youtube
  • HTML APIS
  • HTML Web APIS
  • HTML Geolocation
  • HTML Drag & Drop
  • Web Storage
  • Web Workers
  • HTML SSE
  • HTML Examples
  • HTML Examples
  • HTML Editor
  • HTML Quiz
  • HTML Exercises
  • HTML References
  • HTML Tag List
  • HTML Attributes
  • HTML Global Attributes
  • HTML Brower Support
  • HTML Events
  • HTML Colors
  • HTML Canvas
  • HTML Audio & Video
  • HTML Doctypes
  • HTML Character Sets
  • HTML URL Encode
  • Language Codes
  • HTTP Messages
  • HTTP Methods
  • PX to EM Converter
  • keyboard Shortcuts

The HTML <head> Element

The <head> element is a special section of an HTML document that contains metadata — information about the webpage rather than visible page content.

It is placed between the <html> tag and the <body> tag.

Example

<html>
<head>
<!-- Metadata goes here -->
</head>
<body>
<!-- Metadata goes here -->
</body>
</html>

Metadata is not displayed directly on the webpage. Instead, it provides instructions and information to browsers, search engines, and other web services.

The <head> section can contain the following elements:

  • <title>

  • <style>

  • <meta>

  • <link>

  • <sript>

  • <base>


The <title> Element

The <title> element defines the name of the webpage.

  • It appears in the browser tab.

  • It appears in search engine results.

  • It is shown when a user bookmarks the page.

The <title> tag is required in every HTML document.


Example

<html>
<head>
<title> Learn HTML Basics <title>
</head>
<body>
Page content goes here. </body>
</html>

Why the Title Is Important

  • Helps search engines understand your page.

  • Improves SEO (Search Engine Optimization).

  • Makes your page easier to identify in bookmarks and tabs.

A clear and meaningful title improves user experience and search visibility.


The <style> Element

The <style> element is used to add internal CSS styles to a webpage.

It allows you to define how HTML elements should look.


Example

<style>

body { background-color: lightgray; }

h1 { color: darkblue; }

p { color: black; }

</style>

This CSS applies only to the current HTML document.


The <link> Element

The <link> element connects the current document to an external resource.

It does not display content but helps browsers and search engines understand the page.

Common Uses of <meta>

Define Character Encoding


Example

<meta charset="UTF-8">

Ensures correct display of text and special characters.


Add Page Description

Example

<meta name="description" content="Beginner-friendly HTML tutorials">

Used by search engines in search results.


Add Keywords

Example

<meta name="keywords" content="HTML, CSS, JavaScript, Web Development">

Provides search-related terms (less important in modern SEO but still valid).


Specify the Author

Example

<meta name="author" content="Your Name">


Auto Refresh Page

Example

<meta http-equiv="refresh" content="30">

Reloads the page every 30 seconds.


Viewport Meta Tag (Responsive Design)

The viewport controls how a webpage appears on different devices.

Since screen sizes vary (mobile, tablet, desktop), it is important to include the viewport setting.

Recommended Viewport Tag

Example

<meta name="viewport" content="width=device-width, initial-scale=1.0">

What It Does

  • width=device-width makes the page match the device's screen width.

  • initial-scale=1.0 sets the initial zoom level.


Without this tag, websites may appear zoomed out or improperly scaled on mobile devices.


The <script> Element

The <script> element is used to add JavaScript to a webpage.

JavaScript allows you to create interactive features.

Example

<script>

function showMessage() {
document.getElementById("demo").innerHTML = "Hello JavaScript!";
}

</script>

This script changes the content of an element with the ID demo.


The <base> Element

The <base> element sets a default base URL and/or default target for all relative links in a webpage.

Only one <base> element is allowed per document.

Example

<base href="https://example.com/" target="_blank">

This means:
  • All relative URLs will use https://example.com/ as the starting path.

  • All links will open in a new tab (_blank) unless specified otherwise.


Summary

  • The <head> section stores metadata about the webpage.

  • It is placed between <html> and <body>.

  • <title> defines the page title (required).

  • <style> adds internal CSS.

  • <link> connects external resources like CSS files.

  • <meta> provides page information (charset, description, viewport, etc.)

  • <script> adds JavaScript functionality.

  • <base> defines a default base URL or link target.

Try It Your Self

Sign Up For New
Update

HTML Basic
  1. HTML Basic
  2. HTML Element
  3. HTML Attributes
  4. HTML Headings
  5. HTML Paragrapha
  6. HTML Tables
  7. HTML Lists
HTML Advance
  1. HTML Div
  2. HTML Classes
  3. HTML Id
  4. HTML Buttons
  5. HTML Iframes
  6. HTML Symbols
  7. HTML Emojis