#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 →
HTML Fundamentals

HTML Layout

HTML layout is about dividing a page into meaningful regions such as a header, navigation, main content, sidebar and footer. HTML provides semantic elements for each of these regions, and CSS then arranges them on screen. Using the right elements gives your page a clear structure that browsers, screen readers and search engines understand, before a single style is applied.

The semantic layout elements

  • <header>: introductory content, usually a logo, site name and sometimes navigation. Articles can have their own header too.
  • <nav>: a block of major navigation links, such as the main menu or a table of contents.
  • <main>: the primary content of the page. There should be only one visible <main> per page.
  • <article>: a self-contained piece that would make sense on its own, like a blog post, product card or comment.
  • <section>: a thematic group of content, normally with its own heading.
  • <aside>: content related to the main content but separate from it, such as a sidebar or related links.
  • <footer>: closing information like copyright, contact links or the author of an article.

Screen reader users can jump straight to these regions, called landmarks, which is a huge time saver compared to listening to every line from the top.

A full page skeleton

<body>
  <header class="site-header">
    <h1>City Library</h1>
    <nav>
      <a href="/">Home</a>
      <a href="/books">Books</a>
      <a href="/events">Events</a>
    </nav>
  </header>

  <main>
    <article>
      <h2>Summer Reading Challenge</h2>
      <p>Read five books and earn a badge.</p>
    </article>
  </main>

  <aside>
    <h2>Opening hours</h2>
    <p>Mon to Sat, 9 am to 7 pm</p>
  </aside>

  <footer>
    <p>Contact: help@citylibrary.example</p>
  </footer>
</body>

Arranging the regions with CSS

HTML defines what each region is; CSS decides where it goes. CSS Grid is ideal for whole-page layouts because you can name areas and rearrange them at different screen sizes.

body {
  display: grid;
  grid-template-areas:
    "header"
    "main"
    "aside"
    "footer";
  gap: 16px;
}

@media (min-width: 800px) {
  body {
    grid-template-columns: 3fr 1fr;
    grid-template-areas:
      "header header"
      "main   aside"
      "footer footer";
  }
}

.site-header { grid-area: header; }
main   { grid-area: main; }
aside  { grid-area: aside; }
footer { grid-area: footer; }

On phones the sidebar drops below the main content; on wider screens it moves beside it. The HTML never changes. Flexbox is better suited to smaller one-dimensional pieces, such as lining up links inside the navigation bar.

Older approaches to avoid

Before CSS layout tools matured, developers built page layouts with <table> elements or floated <div>s. Tables for layout confuse screen readers, which announce rows and columns that are not real data. Floats need clearing hacks and break easily. Today, use tables only for tabular data, and use Grid or Flexbox for layout.

Mistakes to watch for

"Div soup" is the most common one: wrapping everything in <div class="header"> and <div class="footer"> when real semantic elements exist. Divs are still fine as styling wrappers, but they carry no meaning. The opposite mistake is using <section> as a generic box; if a block has no natural heading, a <div> is often the more honest choice. Also avoid placing <main> inside <article>, <aside>, <header>, <footer> or <nav>.

Takeaway

Mark up regions with semantic elements first, then position them with Grid for the page frame and Flexbox for smaller rows. This keeps your structure meaningful and your layout flexible across screen sizes.

Ready to master real-world web development?

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

Explore Course