0
0
Bootsrapmarkup~30 mins

Why navigation structure matters in Bootsrap - See It in Action

Choose your learning style9 modes available
Why Navigation Structure Matters
📖 Scenario: You are building a simple website for a local bakery. The bakery wants visitors to easily find important pages like Home, Menu, About Us, and Contact. A clear navigation bar helps visitors move around the site without confusion.
🎯 Goal: Create a basic navigation bar using Bootstrap that includes links to Home, Menu, About Us, and Contact pages. This navigation bar should be easy to read and use on both desktop and mobile devices.
📋 What You'll Learn
Use Bootstrap 5 classes to create a responsive navigation bar
Include four navigation links: Home, Menu, About Us, Contact
Use semantic HTML elements for accessibility
Make sure the navigation bar collapses into a toggle menu on small screens
💡 Why This Matters
🌍 Real World
Navigation bars are essential for websites to help users find information quickly and easily. A well-structured navigation improves user experience and keeps visitors engaged.
💼 Career
Web developers often build navigation menus using frameworks like Bootstrap to create responsive and accessible websites that work well on all devices.
Progress0 / 4 steps
1
Create the basic HTML structure with Bootstrap CSS link
Write the basic HTML5 skeleton including lang="en", meta charset="UTF-8", and meta viewport tags. Add the Bootstrap 5 CSS CDN link inside the <head>. Create an empty <nav> element inside the <body> where the navigation bar will go.
Bootsrap
Need a hint?

Remember to include the Bootstrap CSS link inside the <head> section for styling.

2
Add a Bootstrap container and navbar brand
Inside the existing <nav> element, add a <div> with class container-fluid. Inside this container, add a <a> element with classes navbar-brand and href set to #. The text inside this link should be Bakery.
Bootsrap
Need a hint?

The navbar-brand class styles the main brand or logo link in the navigation bar.

3
Add the navigation links with a collapsible menu
Inside the container-fluid div, add a button with classes navbar-toggler and type="button". Set data-bs-toggle="collapse" and data-bs-target="#navbarNav". Add aria-controls="navbarNav", aria-expanded="false", and aria-label="Toggle navigation". Inside the button, add a span with class navbar-toggler-icon. Below the button, add a div with classes collapse navbar-collapse and id navbarNav. Inside this div, add an unordered list <ul> with class navbar-nav. Inside the list, add four list items <li> each with class nav-item. Each list item contains a link <a> with class nav-link and href set to #. The link texts are Home, Menu, About Us, and Contact respectively.
Bootsrap
Need a hint?

The toggler button allows the menu to collapse on small screens. The collapse navbar-collapse div holds the links that show or hide.

4
Add Bootstrap JavaScript bundle for interactive toggling
Before the closing </body> tag, add a <script> tag that loads the Bootstrap 5 JavaScript bundle from the CDN: https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js. This script enables the toggle button to work on small screens.
Bootsrap
Need a hint?

The Bootstrap JavaScript bundle is needed for the toggle button to open and close the menu on small screens.