What Is HTML Responsive Web Design

HTML Responsive website composition is tied in with making pages that look great on all gadgets!

A responsive website composition will consequently adapt to various screen sizes and viewports.

HTML Responsive

What is HTML Responsive Web Design?

Responsive Web Design is tied in with utilizing HTML and CSS to consequently resize, stow away, recoil, or augment, a site, to make it look great on all gadgets (work areas, tablets, and telephones):

Setting The HTML Responsive Viewport

To create a responsive website, add the following <meta> tag to all your web pages:

Example

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

This will set the viewport of your page, which will give the program guidelines on the most proficient method to control the page’s measurements and scaling.

Here is an illustration of a website page without the viewport meta tag, and a similar page with the viewport meta tag:

HTML Responsive Images

Responsive pictures are pictures that scale pleasantly to fit any program size.

Using the width Property

In the event that the CSS width property is set to 100%, the picture will be responsive and increase and down:

HTML Responsive
Example

<img src=”img_girl.jpg” style=”width:100%;”>

Notice that in the model over, the picture can be increased to be bigger than its unique size. A superior arrangement, much of the time, will be to utilize the maximum width property all things considered.

Using the max-width HTML Responsive Property

On the off chance that the maximum width property is set to 100%, the picture will downsize in the event that it needs to, yet never increase to be bigger than its unique size:

HTML Responsive
Example

<img src=”img_girl.jpg” style=”max-width:100%;height:auto;”>

Show Different Images Depending on Browser Width

The HTML <picture> element allows you to define different images for different browser window sizes.

Resize the program window to perceive how the picture underneath change contingent upon the width:

HTML Responsive
Example

<picture>
  <source srcset=”img_smallflower.jpg” media=”(max-width: 600px)”>
  <source srcset=”img_flowers.jpg” media=”(max-width: 1500px)”>
  <source srcset=”flowers.jpg”>
  <img src=”img_smallflower.jpg” alt=”Flowers”>
</picture>

HTML Responsive Text Size

The text size can be set with a “vw” unit, which means the “viewport width”.

That way the content size will follow the size of the program window:

Hello World

Resize the program window to perceive how the content size scales.

Example

<h1 style=”font-size:10vw“>Hello World</h1>

HTML Responsive Media Queries

Notwithstanding resize text and pictures, it is additionally not unexpected to utilize media inquiries in responsive website pages.

With media questions you can characterize totally various styles for various program sizes.

Example: resize the program window to see that the three div components underneath will show evenly on enormous screens and stacked upward on little screens:

HTML Responsive
Example

<style>
.left, .right {
  float: left;
  width: 20%; /* The width is 20%, by default */
}

.main {
  float: left;
  width: 60%; /* The width is 60%, by default */
}

/* Use a media query to add a breakpoint at 800px: */
@media screen and (max-width: 800px) {
  .left, .main, .right {
    width: 100%; /* The width is 100%, when the viewport is 800px or smaller */
  }
}
</style>

Tip: To learn more about Media Queries and Responsive Web Design, read our RWD Tutorial.

HTML Responsive Web Page – Full Example

A responsive website page should look great on enormous work area screens and on little cell phones.

Example

<!DOCTYPE html>
<html>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://www.Examples.com/e.gcss/4/e.g.css”>
<body>

<div class=”e.g-container e.g-green”>
  <h1>Examples Demo</h1>
  <p>Resize this responsive page!</p>
</div>

<div class=”e.g-row-padding”>
  <div class=”e.g-third”>
    <h2>London</h2>
    <p>London is the capital city of England.</p>
    <p>It is the most populous city in the United Kingdom,
    with a metropolitan area of over 13 million inhabitants.</p>
  </div>

  <div class=”e.g-third”>
    <h2>Paris</h2>
    <p>Paris is the capital of France.</p>
    <p>The Paris region is one of the biggest populace places in Europe,
    with more than 12 million inhabitants.</p>
  </div>

  <div class=”e.g-third”>
    <h2>Tokyo</h2>
    <p>Tokyo is the capital of Japan.</p>
    <p>It is the focal point of the Greater Tokyo Area,
    and the most populous metropolitan area in the world.</p>
  </div>
</div>

</body>
</html>

HTML Responsive Bootstrap

Another well known CSS system is Bootstrap. Bootstrap utilizes HTML, CSS and jQuery to make responsive pages.

Example

<!DOCTYPE html>
<html lang=”en”>
<head>
<title>Bootstrap Example</title>
<meta charset=”utf-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
</head>
<body>

<div class=”container”>
  <div class=”jumbotron”>
    <h1>My First Bootstrap Page</h1>
  </div>
  <div class=”row”>
    <div class=”col-sm-4″>
      …
    </div>
    <div class=”col-sm-4″>
      …
    </div>
    <div class=”col-sm-4″>
    …
    </div>
  </div>
</div>

</body>
</html>