Making websites that display well across all platforms is the goal of responsive (HtmL Responsive) web design!
A responsive web design will adapt to various viewport sizes and screen sizes on its own.
What is Responsive Web Design?
Using HTML and CSS to automatically resize, hide, shrink, or enlarge a website so that it looks well on computers, tablets, and phones is known as responsive web design:
Setting The Viewport
Add the following <meta> tag to each and every one of your web pages to make your website responsive:
Example
This will configure your page’s viewport, which will instruct the browser on how to manage the page’s scaling and dimensions.
The following is an illustration of a webpage with and without the viewport meta tag:
Responsive Images
A responsive image is one that adapts well to the size of the browser.
Using the width Property
When the CSS widthproperty is 100%, the picture will scale up and down and be responsive:
Example
It is possible to enlarge the image in the example above beyond its initial dimensions by applying a scaling technique. In many circumstances, using the max-width attribute will be a superior option.
Using the max-width Property
The image will resize to fit if necessary if the max-widthproperty is set to 100%, but it will never enlarge to fill the screen:
Example
Show Different Images Depending on Browser Width
You can define different images for different browser window sizes with the HTML <picture> element.
Try resizing the browser window to observe how the width affects the image below:
Example
Responsive Text Size
The “viewport width” (abbreviated “vw”) unit can be used to adjust the text size.
In this manner, the text size will match the browser window’s size:
Hello World
Resize the browser window to see how the text size scales.
Example
Hello World
Media Queries
In responsive web pages, media queries are frequently used in addition to text and picture resizing.
You can specify entirely distinct styles for various browser widths using media queries.
For instance, you can resize the browser window to observe that the three div elements below will stack vertically on small screens and appear horizontally on large ones:
Left Menu
Main Content
Right Content
Example
Responsive Web Page - Full Example
Both small mobile phones and large desktop devices should display well on a responsive website.
Responsive Web Design - Frameworks
All popular CSS Frameworks offer responsive design.
They are free, and easy to use.
Codingask.CSS
Codingask.CSS is a modern CSS framework with support for desktop, tablet, and mobile design by default.
Codingask.CSS is smaller and faster than similar CSS frameworks.
Codingask.CSS is designed to be independent of jQuery or any other JavaScript library.
W3.CSS Demo
Resize the page to see the responsiveness!
London
London is the capital city of England.
It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
Paris
Paris is the capital of France.
The Paris area is one of the largest population centers in Europe,
with more than 12 million inhabitants.
Tokyo
Tokyo is the capital of Japan.
It is the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.
Example
W3.CSS
Codingask Demo
Resize this responsive page!
Berlin
Berlin is the capital city of Germany.
It is the most populous city in the Germnay,
with a metropolitan area of over 3.85 million inhabitants.
Oslo
Oslo is the capital of Norway.
The Oslo area is one of the largest population centers in Norway,
with more than 0.65 million inhabitants.
Tokyo
Tokyo is the capital of Japan.
It is the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.