#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
CSS3 Fundamentals

HTML Head

The <head> element holds information about a web page rather than content shown on it. It sits between <html> and <body> and contains the page title, character encoding, viewport settings, links to stylesheets, scripts and metadata used by browsers and search engines. Getting the head right is what makes your CSS load, your text display correctly and your page look good on phones.

What normally goes inside

A typical head for a modern page looks like this:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Pizza Menu | Tony's Kitchen</title>
  <meta name="description" content="Wood-fired pizzas, sides and drinks.">
  <link rel="icon" href="/favicon.ico">
  <link rel="stylesheet" href="css/reset.css">
  <link rel="stylesheet" href="css/style.css">
  <style>
    body { margin: 0; }
  </style>
  <script src="js/app.js" defer></script>
</head>
<body>
  ...
</body>
</html>

Each line has a job:

  • <meta charset="utf-8"> tells the browser how to decode the file's bytes into characters, so symbols like ₹, é or Hindi text show correctly.
  • <meta name="viewport"> makes mobile browsers use the device width, which is required for responsive CSS.
  • <title> is the text in the browser tab, in bookmarks and usually in search results. Every page should have a unique, descriptive one.
  • <meta name="description"> is a short summary that search engines may show under the title.
  • <link> connects external resources, most often stylesheets and the favicon.
  • <style> holds CSS written directly in the page, and <script> loads JavaScript.

Why order matters for CSS

This module is where CSS starts, and the head is where you connect it. Stylesheets are applied in the order they appear. When two rules have the same specificity, the one that comes later wins. That is why a reset or framework stylesheet goes first and your own stylesheet comes after it, so your rules can override the defaults. An internal <style> block placed after the links will override both for equal-specificity selectors.

Paths in href are relative to the HTML file unless they start with a slash. A path like css/style.css looks for a css folder next to the HTML file. A wrong path fails silently: the page just appears unstyled, so check the Network tab in developer tools when styles do not load.

Scripts in the head without slowing the page

A plain <script src> in the head stops the browser from reading the rest of the HTML until the script downloads and runs. The defer attribute downloads the script in parallel and runs it after the document is parsed, in order. That makes the head a safe place for scripts and means your code can find elements in the body. The async attribute also downloads in parallel but runs as soon as possible, in any order, which suits independent scripts like analytics.

Common errors

Putting visible elements such as headings or images in the head is invalid. Browsers will quietly move them into the body, which can produce confusing layouts. Another mistake is placing the charset declaration late. It should be the first element in the head, because the browser must know the encoding before it reads any text. Forgetting the lang attribute on <html> is also common; screen readers use it to choose pronunciation.

Takeaway

Treat the head as the page's settings panel: charset first, then viewport, a unique title and description, stylesheets in the right override order, and scripts with defer. With that in place, the CSS you write in the coming lessons will load and apply exactly as expected.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course