

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a responsive website that will work on all devices, PC, laptop, tablet, and phone?
To create a responsive website that will work on all devices, the code is as follows −
Example
<!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 −
- Related Questions & Answers
- How to create different device looks (smartphone, tablet and laptop) with CSS?
- How to create a responsive website with Bootstrap 4?
- How to design a responsive website?
- How can I improve performance of a Laptop or PC?
- How to detect device is Android phone or Android tablet?
- Is it necessary to have a responsive website?
- How to boost internet security on smartphones and pc
- How to lock screen orientation on all android devices programmatically?
- How to change NAT type on PC
- How to detect if a user is using an Android tablet or a phone using Kotlin?
- How to work with JavaScript Drag and drop for touch devices?
- How to create a responsive slideshow with CSS and JavaScript?
- What is the easiest way to transfer files from phone to PC?
- How to create a responsive slideshow gallery with CSS and JavaScript?
- How to create a responsive Image Grid with HTML and CSS?
Advertisements