-
Hajipur, Bihar, 844101
A navigation bar (nav bar) is a section of a website that contains links to other parts of the site. It is commonly placed at the top or side of a webpage and styled using CSS to enhance usability and appearance.
Horizontal Navbar – Usually at the top of the page
Vertical Navbar – Typically used for side navigation
Fixed Navbar – Stays in place during scroll
Responsive Navbar – Adjusts layout on different screen sizes
<nav>
<ul class="navbar">
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
.navbar {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #333;
overflow: hidden;
display: flex;
}
.navbar li a {
display: block;
color: white;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
.navbar li a:hover {
background-color: #111;
}
.navbar {
display: flex;
flex-direction: column;
width: 200px;
}
.fixed-navbar {
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
@media screen and (max-width: 600px) {
.navbar {
flex-direction: column;
}
}
Q1. Create a horizontal navigation bar with four links.
Q2. Style the nav bar with a dark background and white text.
Q3. Add hover effects to change link background color.
Q4. Make the navigation bar fixed at the top.
Q5. Create a vertical sidebar navigation bar.
Q6. Use Flexbox to align links horizontally.
Q7. Center the navigation links in the nav bar.
Q8. Add padding and spacing between links.
Q9. Make a responsive navigation bar using media queries.
Q10. Highlight the active link in a different color.
Q1: Which HTML tag is commonly used for navigation?
Q2: Which property removes bullet points from a nav list?
Q3: What does display: flex; do in a nav bar?
Q4: How to style links with no underline?
Q5: Which property is used to make a fixed nav bar?
Q6: How do you change the background of a hovered link?
Q7: What does overflow: hidden; do in nav?
Q8: Which tag creates a link in a navbar?
Q9: How to stack nav links vertically using Flexbox?
Q10: Which media query makes nav responsive on small screens?