University of New Hampshire, Department of Computer Science

Information Technology 502
, Intermediate Web Design

Spring 2024

Jump to navigation

Design Template by Anonymous

Responsive Design

As businesses and web designers have begun distancing themselves from mobile-independent websites, the interest has grown in another methodology. This is called responsive design. Responsive design in the context of mobile web design is the approach of creating websites that adapt and respond to the user’s device and screen size. It further involves designing websites in a way that ensures they display and function optimally across a wide range of devices, including smartphones, tablets, and desktop computers. To explain this further, I have compiled a couple of common responsive design practices and their purpose in this process.


Examples:

Media Queries

Media queries allow you to apply different CSS styles based on various factors like screen width, height, orientation, etc. This enables you to create specific layouts for different devices. This process becomes much easier when focusing on building around mobile-first.

I thought it fitting to showcase this ability, and have created an example fitting of the code example provided that will showcase how backgrounds can be changed based on window/screen size. In this example, you will see that when viewing the sample web page on a desktop screen, the background will appear as light blue. When the same page is viewed on a mobile screen, the background will appear as pink instead. This is all done through media queries, and this is only the tip of the iceberg.

Media querie code
Code created for the example below.

Media querie example on iPhone
iPhone view, made using W3Schools HTML emulator.

Media querie example on Desktop
Desktop view, made using W3Schools HTML emulator.

With the proliferation of new devices and screen sizes, media queries have become more crucial than ever. Media queries will provide a flexible and scalable approach to mobile web design. Implementing media queries can future-proof a website, and make sure it remains accessible to users on a wide range of devices. Content prioritization comes into the picture as well, with media queries having the unique ability to present the most important content first based on a user’s screen size and technical abilities. This practice is directly in line with the main building block of Mobile-First Design, creating a content hierarchy, and pushing that information first on your site.

Viewport Meta Tag

Use the viewport meta tag to control the width and scaling of the viewport. This ensures that the webpage is rendered at the appropriate width and scale on mobile devices.

Code example for meta tag
Code example using the meta tag.

This meta tag tells the browser to set the width of the viewport to the device's width and scale the initial size of the webpage to 1.0 (i.e., no zoom). This ensures the webpage renders properly on various devices and adapts to different screen sizes. Zooming should be avoided at all costs when making a mobile website. The screen is already small enough and all information should be made available easily and fast without extra steps. Removing the need to zoom at all keeps simplicity at the forefront. Meta tags can also be used to ensure that text and interactive elements are appropriately sized to their respective viewport. Increasing the readability and usability for the website's users is important for the general audience, or even further for disabled users who may be using your website along with assistive technologies on their devices.

Flexible Images and Media

Set max-width: 100%; for images and media elements to prevent them from overflowing their containers on smaller screens. This ensures that images scale down proportionally with the screen size.

Code example for max-width
Code example using max-width: 100%.

max-width: 100% will ensure that the image doesn't overflow its container, allowing it to scale down proportionally with the screen size. If you combine this with height: auto;, the aspect ratio will retain for the respective image. This simple addition can remove all instances of squishing and distortion on different screen sizes. There is more. Images larger than necessary can significantly impact page load times, which can be seen even harsher on mobile devices with slower connections. A smaller, more fit image will reduce the amount of data that needs to be transferred and rendered. Images that adapt will ultimately provide the best experience to the mobile user.