Create a responsive navigation menu with CSS Media Queries

CSSWeb DevelopmentFront End Technology

Media Queries is used when you need to set a style to different devices such as tablet, mobile, desktop, etc.

You can try to run the following code to create a responsive navigation menu with Media Queries:


Live Demo

<!DOCTYPE html>
<html lang = "en">
      <meta charset = "utf-8">
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
         .demo {
            overflow: hidden;
            background-color: blue;
         .demo a {
            float: left;
            display: block;
            color: white;
            text-align: center;
            padding: 10px;
            text-decoration: none;
         @media screen and (max-width: 600px) {
            .demo a {
               float: none;
               width: 100%;
      <p>Navigation Menu:</p>
      <div class = "demo">
         <a href = "#">Home</a>
         <a href = "#">About</a>
         <a href = "#">Tutorials</a>
         <a href = "#">QA</a>
         <a href = "#">Videos</a>
         <a href = "#">Contact</a>
Updated on 24-Jun-2020 08:40:53