Write an HTML program to create a navigation menu
Description: Create a navigation menu with the links Home, About, Services and Contact, shown in one line.
Hint:
- A menu is a list of links, so use
ul,liandainside anavtag. - Use CSS to remove the bullets and show the items in one line.
HTML navigation menu
<nav>
<ul class="menu">
<li><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
<style>
.menu { list-style: none; padding: 0; }
.menu li { display: inline-block; margin-right: 15px; }
</style>
Output in the browser:
Output in the browser
How it works
- The
navtag tells that this block has navigation links. list-style: noneremoves the bullets, anddisplay: inline-blockputs the items in a row.
Read HTML Semantic Elements.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |