
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
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 Articles
- 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 detect if a user is using an Android tablet or a phone using Kotlin?
- How to lock screen orientation on all android devices programmatically?
- How to boost internet security on smartphones and pc
- How to create a responsive slideshow with CSS and JavaScript?
- What is the easiest way to transfer files from phone to PC?
- How to change NAT type on PC
- How to create a responsive header with CSS?
- How to create a responsive image with CSS?
- How to create a responsive form with CSS?

Advertisements