How to create a responsive website that will work on all devices, PC, laptop, tablet, and phone?

CSSWeb DevelopmentFront End Technology

To create a responsive website that will work on all devices, the code is as follows −

Example

 Live Demo

<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   * {
      box-sizing: border-box;
   }
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      margin: 0;
   }
   .header {
      padding: 80px;
      text-align: center;
      background: #7b1abc;
      color: white;
   }
   .header h1 {
      font-size: 40px;
   }
   nav {
      width: 100%;
      background-color: rgb(39, 39, 39);
      overflow: auto;
      height: auto;
   }
   .links {
      display: inline-block;
      text-align: center;
      padding: 14px;
      color: rgb(178, 137, 253);
      text-decoration: none;
      font-size: 17px;
   }
   .links:hover {
      background-color: rgb(100, 100, 100);
   }
   .selected {
      background-color: rgb(0, 18, 43);
   }
   main {
      background-color: white;
      padding: 20px;
   }
   .footer {
      padding: 20px;
      text-align: center;
      color: white;
      background: rgb(255, 0, 0);
   }
</style>
</head>
<body>
<div class="header">
<h1>Website ↶</h1>
</div>
<nav>
<a class="links selected" href="#"> Home</a>
<a class="links" href="#"> Login</a>
<a class="links" href="#"> Register</a>
<a class="links" href="#"> Contact Us</a>
<a class="links" href="#">More Info</a>
</nav>
<main>
<h2>Sample Heading</h2>
<h5>Published in January</h5>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, autem.
</p>
<br />
<h2>Sample Heading</h2>
<h5>Published in march</h5>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Unde quo minus fugiat tempora quae ratione dignissimos exercitationem voluptate officiis reiciendis.
</p>
</main>
<div class="footer">
<h2>Footer ↷</h2>
</div>
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 12-May-2020 15:59:52
Advertisements