A web page is divided into areas such as a header, menu, content and footer. The div tag and its semantic relatives build this layout.

The DIV Tag

<div> (division) is a generic block-level container. By itself it has no visible effect, but it groups elements so that they can be styled and positioned together with CSS, using a class or id attribute. A page is commonly built from divs: one for the header, one for the menu, one for the main content and one for the footer. <span> is the matching inline container.

Definition: Navigation bar. A section of a web page, usually at the top or side, that contains links to the main pages or sections of the site, built from a list of links styled with CSS.

Semantic Layout Tags

HTML5 adds semantic tags that act like divs but say what each part is: <header> (page or section heading), <nav> (navigation links), <main> (main content), <section> (a themed group of content), <article> (a self-contained item such as a post), <aside> (side content) and <footer> (page footer). They help search engines and screen readers, and make the code easier to read.

Designing a Navigation Bar

A navigation bar (navbar) is usually an unordered list of links inside a <nav> element. With CSS, the list bullets are removed (list-style: none), the items are placed side by side (display: inline-block, or display: flex on the list), the links get padding and colours, and :hover changes the colour when the mouse is over a link. A class such as active marks the current page. For small screens, the navbar can be stacked vertically or collapsed into a "hamburger" menu, which Bootstrap provides ready-made (Unit II).

Page Layout with Divs and CSS

CSS arranges the divs: Flexbox (display: flex) places items in a row or column, and Grid (display: grid) arranges them in rows and columns, for example a sidebar and a content area. Width, margin and padding control spacing.

Table 1.6: Semantic layout tags

Tag Purpose Typical content
<header> Top of page or section Logo, title
<nav> Navigation Menu links
<main> Main content Articles, sections
<aside> Side content Notices, ads
<footer> Bottom of page Contact, copyright

Example 1.6: A page with a navbar

Problem: Build the skeleton of a college home page with a header, a horizontal navbar with four links, a main section and a footer.

Solution:

  1. Use <header>, <nav> with a <ul> of links, <main> and <footer>.
  2. In CSS, remove list bullets, display the items side by side, and colour the links.
  3. Add a hover effect and an active class for the current page.

Result: A page with a clear layout and a horizontal menu that changes colour on hover.

<style>
  nav ul { list-style: none; margin: 0; padding: 0;
           display: flex; background: #1F3864; }
  nav a  { display: block; padding: 12px 18px;
           color: white; text-decoration: none; }
  nav a:hover, nav a.active { background: #C00000; }
  footer { text-align: center; padding: 10px; background: #eee; }
</style>
<header><h1>DPG College</h1></header>
<nav>
  <ul>
    <li><a class="active" href="index.html">Home</a></li>
    <li><a href="courses.html">Courses</a></li>
    <li><a href="faculty.html">Faculty</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>
<main><div class="content"><p>Welcome to our college.</p></div></main>
<footer>&copy; 2026 DPG College</footer>

Common mistakes

  • Using div for everything when a semantic tag such as nav or footer fits.
  • Leaving the default list bullets in a horizontal navbar.
  • Forgetting to mark the current page in the navbar.

Key takeaways

  • <div> is a block container and <span> an inline one, styled with CSS.
  • Semantic tags (header, nav, main, section, article, aside, footer) describe page parts.
  • A navbar is a list of links in <nav>, styled to sit side by side.
  • Flexbox and Grid arrange layout.

Practice questions

  1. What is the div tag used for?
  2. Which HTML5 tag should contain the main menu?
  3. How are list items placed side by side in a navbar?

Answers to the practice questions

  1. To group elements into a block so that they can be styled and positioned with CSS.
  2. <nav>.
  3. With CSS, for example display: flex on the list or display: inline-block on the items.

Sources

  • Official BCA syllabus Web Technologies, course code 25BCA402SEC02, Unit I