The Celebration Mall, Amritsar

Responsive navigation code in HTML

Simple and easy way to make a responsive navigation bar for Mobiles and websites using HTML and CSS.

Languages used – HTML, CSS, JavaScript.

<html>
    <head>
        <title>My Page</title>
    </head>
    <body>
        <nav id="nav">
            <a>Home</a>
            <a>News</a>
            <a>Contact</a>
            <a>About</a>
        </nav>
    </body>
</html>
<style>
    body{
        margin: 0px auto;
    }
    nav{
        width: 100%;
        margin: 0px auto;
        background-color: #046ec9;
        height: 35px;
        text-align: center;
        }
    nav a{
            background-color: white;
            color: black;
            width: 23%;
            float: left;
            margin: 0% 1%;
            margin-top: 9px;
            }
    nav a:hover{
            background-color: black;
            color: white;}
    @media only screen and (max-width:600px){
    nav a{
        width: 98%;
        }
    nav {
        height: 117px;
        }
    }
</style>

Leave feedback about this

  • Quality
  • Price
  • Service
Choose Image