Building a screen responsive webpage
Published: 2020-06-29 12:54:25

Now more than ever, websites are getting viewed more often on a smaller screen.  "... In 2019, 52.2 percent of traffic came from mobile phones." [(via. Internet Usage Statistics)](https://www.broadbandsearch.net/blog/mobile-desktop-internet-usage-statistics). And that percentage is not even including tablets. The trend has smaller screen webpage views going up and typical computer screen views going down. That means if you are developing a website (for anything other than small projects), you should keep this trend in mind. A good developer builds your users' foundation on an HTML landscape that can adapt to different screen sizes. 

How do you use HTML and CSS to automatically resize, shrink, or enlarge a website and make it look good on all devices? Well, that is a loaded question. Some developers are great at customizing CSS that can fluidly resize on different screens. Others utilize front end libraries that can produce great looking and adaptable website with just a few utility classes. The choice is up to you and your team. I can show you a couple of options that may make your choice a little easier. 

__The basics to making HTML more responsive to screen size:__

Let's being by taking a look at a webpage built with vanilla HTML, zoomed to mimic a Moto G4 cellphone screen.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wag2mj7ky90pd0rk4841.jpg)

The text looks pretty good. But the horse photo is not the size I wanted due to a lack of scaling the dimensions of the image. The screen is smaller, but the picture is still displayed as if on a computer monitor. To fix this, we can add the following <meta> tag inside our HTML head. 

```html
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
```
Here we are, with the photo filling up the entire screen. Not quite responsive all together but much closer to what I was expecting.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/trj7ozmxt2t26p15iowf.jpg)

If you would like to make your HTML images and components respond even better to screen size changes, you can begin by following the guide on [W3schools - responsive HTML (https://www.w3schools.com/html/html_responsive.asp). Now I would like to show you three front-end frameworks that can do some of that work for you and give you many more options for style and functionality. 

__1. Bootstrap__

The first framework that I will introduce is the most popular. With Bootstrap, designing for smaller screen sizes is no longer a separate project in itself. If you include the relevant Bootstrap classes, the design will automatically adjust for different screen sizes.


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wrnmt4iguh8tg11mdjbw.jpg)

The code below courtesy of [bootStrap docs](https://getbootstrap.com/docs/4.5/getting-started/introduction/)
```html
    <div class="jumbotron">
      <h1 class="display-3">Jumbotron heading</h1>
      <p><a class="btn btn-lg btn-success" href="#" role="button">Sign up today</a></p>
    </div>
```

Let's Consider the impressive [documentation](https://getbootstrap.com/docs/4.1/getting-started/introduction/) library and the large scale community online. FullStack developers who want a straightforward framework with a large community have a lot to like about BootStrap.

__Pros:__

_Easy to pick up and use:_ apply the right CSS utility classes to your standard HTML components, and you can have a sharp-looking and responsive web page. A beginner can install the script and begin building their front end with little research. 

_A large community:_ By large, I mean massive. Bootstrap is the most popular front-end framework out there, and because of that, you will almost certainly find the solution to most code-related problems. Just google an error or a design you would like to build, and you will likely find the answer. 

__Cons:__

_A little too popular:_ The biggest con I continuously read about from experienced front end developers is how boring a Bootstrap layout can become. (I am not yet tired of the look) because Bootstrap offers so many pre-built components, out of the box, the internet has become populated with website styles that look very similar to one another. BootStrap can become dull for a more experienced designer wanting to create a fresh look. 

__2. Tailwind CSS__

Another less popular utility class-based framework would be TailWind CSS. Tailwind has a set of small CSS class names that you can use to change your element's style. Let's check out what a Tailwind website can look like on the small screen. 

//Tailwind example
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/22zcptjid0tdxuvq3qrx.jpg)

code below courtesy of [fifthre.com](https://fifthnre.com/?ref=builtwithtailwind.com) 
```html
  <div class="section__side relative z-30 bg-fifth-dark-green">
    <span class="side-text">
      <span class="font-tuesday normal-case">The</span> sweet spot <span class="line h-10 bg-fifth-yellow inline-block"
        style="width: 1px;"></span>
      <a href="https://www.instagram.com/fifthnre/" target="_blank"><i class="fab fa-instagram text-xl mb-2"
          aria-hidden="true"></i></a>
      <a href="https://www.facebook.com/FIFTHNRE/" target="_blank">
        <i class="fab fa-facebook-square text-xl mb-2" aria-hidden="true"></i>
      </a>
      <a href="https://www.tripadvisor.nl/Restaurant_Review-g188582-d17733481-Reviews-Fifth_NRE-Eindhoven_North_Brabant_Province.html"
        target="_blank">
        <i class="fab fa-tripadvisor text-xl" aria-hidden="true"></i>
      </a>
    </span>
  </div>
```
__Pros:__

_Also easy to use:_ Tailwind makes use of utility-first classes that are reusable and customizable. I continue to read about developers who are unsure about the framework at first, but they can't put it down when they use it. For example, the fluid, container, or text-color classes that you can pop right into your div class to give it the utility and style you want. 

_A unique look compared to Bootstrap:_ I feel that a tailwind website has sharper edges and a more minimal, cleaner look than bootStrap. (But that is just opinion) The boxes seem to pop out and make you focus on the content of the containers. Great if you've already designed a dozen sites in bootStrap and want something new. 

_small community?:_ Yeap, this can be a pro for some designers. There is a sense of accomplishment in designing a beautiful and responsive website in a less popular framework. It can be a joyful challenge to know that you will have to read the docs and experiment independently. 

__Cons:__

_Code can become crowded:_ Utility-first CSS is excellent for functional and clean looking websites, but the implementation can get a little rough as you build more complicated code. Even in the above code snippet, you can see the elements and classes are getting crowded, unlike other designs where you may have more utility or style separated in a CSS file.  

_Smaller Community:_ This con would be for those developers that are not looking for the accomplishment of building a beautiful website with a framework that has less support and pre-build components. Some full-stack builders would prefer easy examples and resources for their front end so they can concentrate on other parts of their site.

__3. Bulma__


Bulma is a relatively new framework, but its popularity has snowballed in a short amount of time. Its attractiveness lies in a strict, CSS-only approach (there are no JavaScript components) and elegant default classes, making many developers tired of BootStrap sigh in relief. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/msr111a30lafu60mcqll.jpg)

The code below is courtesy of [Free Bulma Templates](https://bulmatemplates.github.io/bulma-templates/)
```html
  <section class="hero">
    <figure class="image">
      <img
        src="https://images.pexels.com/photos/167636/pexels-photo-167636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
    </figure>
  </section>

  <section class="section">
    <div class="container has-text-centered">
      <h2 class="title">The Band</h2>
      <p>We have created a fictional band website... </p>
    </div>
  </section>
```
__Pros:__

_popular_: Not quite as popular as Bootstrap, but the Bulma community is dedicated, and the support online is more significant than many other frameworks. Bulma is an excellent option if you are looking for that different style but with a lot of community help. 

_easy learning curve_ Bulma has easy to understand class names and is built to be more modular and solve practical, everyday problems. You may find that Bulma is straightforward to learn even with just a little background in CSS. 

__Cons:__

_Some Compatibility issues:_ The CSS of this framework runs very slow on IE web browser. IE compatibility may not be much of a problem because many frameworks, i.e., Bootstrap 5, are dropping support for IE altogether. 

_Still in development stage:_ Meaning there are still many updates to come, and the actual documentation still has a lot of growing to do.

__Conclusion__ 

If you want to continue learning about these or other front-end frameworks, I linked some excellent resources below. Ankush Thakur wrote a great article about the '10 Best CSS Frameworks for Front-End Developers'. But whichever path you and your team choose to develop a visually stunning and responsive website, I know you will have success. 

__What is your favorite front end framework?__

And as always:
Stay focused || Love your code


## Resources:

1. [W3schools - responsive HTML](https://www.w3schools.com/html/html_responsive.asp)

2. [Mobile VS Desktop internet usage](https://www.broadbandsearch.net/blog/mobile-desktop-internet-usage-statistics)

3. [pros and cons of bootstrap web development] (https://skat.tf/pros-cons-bootstrap-web-development/)

4. [10 Best front-end frameworks](https://geekflare.com/best-css-frameworks/)

5. [Free Bulma Templates](https://bulmatemplates.github.io/bulma-templates/)