While running a business, the best reward you can get is customer satisfaction. The biggest brands and industry leaders have raised their product quality, improved their customer service, and fastened their delivery to achieve the holy grail of sales that only comes from customer loyalty and word of mouth.
Over the last few years, with the popularity of online channels, businesses have transitioned into digital platforms. Now they use websites as their one-stop access points, where consumers can not only learn about their products and shop; but also share their opinions and seek assistance if required.
But what happens when their experience on your website gets hampered by challenging-to-use and unattractive web designs? They leave the website and barely come back. Since websites are no longer accessed only through computers, companies need to focus on showcasing responsive web designs.
In this blog, we will share a tutorial on creating a responsive web design in CSS. But first, let us discuss some basic concepts.
What is a Responsive Web Design?
Websites are viewed on a variety of devices today, each with a different size of display. A responsive web design is an approach to web design that helps to display web pages on a variety of displays, windows or screen sizes.
What is CSS?
CSS stands for Cascading Style Sheets. It is a style sheet language that is used to describe the presentation of a document or a page, written in a mark up or coding language such as HTML.
CSS describes how the elements of HTML are going to be displayed on a screen, paper or other media.
Why create a responsive web design in CSS?
94% of people judge a website based on its responsiveness.
Google prioritizes responsive designs.
50% of the total eCommerce revenue comes from cell phones.
72% of consumers prefer mobile-friendly websites.
There are more of these stats and facts that shout out the importance of getting a responsive web design.
Now, since responsive web designs only use HTML and CSS, designers must create them. In fact, it is called a responsive web design when you use CSS and HTML to shrink, hide, resize, enlarge, or move the contact to make it look good on various screens.
Now that we are thorough with the basics, let's jump into the real topic:
How to create a responsive Web Design in CSS?
Let us begin by saying that designing a website is no child's play and requires a substantial amount of skill and expertise. Designers spend years learning this art, and we can barely cover all of the knowledge in one blog. There are software that let's you do it yourself, but even then you need to spend some significant time on it.
#Step 1 The Layout
Our first tip regarding responsive design is taking one step at a time.
While creating a responsive web design from scratch or redesigning an existing page for responsive design, the first thing to focus on is the layout. Up to 38% of consumers will stop engaging with a website if the content layout is unattractive. So it is the first element to take care of while designing.
You can always start with creating a non-responsive layout design as per the default size. Once you are content with the layout on the non-responsive page, you can add media queries and make the required alterations to the code to make the design responsive.
After you are done with the non-responsive website, paste the following lines within the <head> and </head> tags of your HTML page. What does it do? It sets the view on all screens at 1 x 1 aspect ratio and removes the default feature on smartphone browsers that displays websites in full size and allows users to zoom into the layout by pinching.
At this stage, you will add the media queries. Since they depend on the respective website's layout, we cannot provide you with ready-made codes. However, you can consider the following image for reference.
Here, #primary is the main content area, and #secondary is the sidebar.
You can adapt and customize this code as per your requirements.
#Step 2 Medias
Now that you are done with your layout, we get into another vital part of a website design: adding media, such as videos and images.
We are sharing a simple CSS code that works on almost all websites. This code will make sure that your images are never bigger than their parent container. In other words, they will adjust themselves to the device size it is displayed on. Enter this code into your CSS stylesheet, and that's all.
Now, let's get into another popular type of media for modern websites, videos. Most websites today are embedding videos from social media platforms or third party sites. These channels include YouTube, Vimeo, etc. The code we are going to share will allow you to make these embedded videos responsive.
The HTML code:
The CSS code:
#Step 3 Typography
Typography is another intricate part of web designing that often gets ignored by designers. We recommend a focused approach to this module as well.
Now, when we get into typography, there are certain changes that we need to adapt while shifting from a non-responsive to responsive website. Previously, designers used pixel to define font sizes. Pixel works perfectly when using a fixed width size.
However, a responsive website needs a responsive font which is also related to its parent container, so it can adjust to the viewer's screen. The CSS3 introduced a new unit called rems. The are identiall to the em unit in terms of functionality, but are connected to the HTML element. This makes rems a lot more user friendly than ems.
Pro tip: Don't forget to reset the HTML font size.
Now you can define responsive font dimensions as depicted bellow:
Lastly, we recommend you to implement a fallback, as the rem unit is not recognized by older browsers.
There is nothing more satisfying about having something tailor-made for your requirements, right? That's exactly what the visitors on your landing page should feel, no matter what device they are using to access it. An appealing design and a beautiful layout can do a lot more good than you can estimate.