How to make your website responsive or mobile friendly?

How to make your website responsive or mobile friendly?

With such a large number of individuals on the planet utilizing cell phones to surf the web, increasingly website admins are searching for routes in which they can make their sites versatile benevolent. This as a rule implies changing their locales for the littler screen measure found on such gadgets, either by giving a different page that can be seen easily there, or, all the more normally, making their sites naturally adjust by contracting things and moving stuff around. The last strategy, regularly alluded to as "responsive website composition", is portrayed in this instructional exercise arrangement.


Since this instructional exercise manages the progressions you have to make to your site's low level code, you should know some HTML and CSS. You don't should be a specialist or anything like that, however some information is vital, generally this instructional exercise will be misty to you.

By chance, in the event that you are here on the grounds that you pondered planning a site sans preparation, please read How to Create a Website.

Responsive Web Design

In responsive outline, we will introduce a similar site page that desktop or tablet phone see to your portable gathering of people. Just the Cascading Style Sheets, or CSS, will be distinctive. That is, programs on desktop/PCs render the page utilizing one arrangement of CSS guidelines, while those on cell phones another.

This technique for working not just spares you the work of making an alternate arrangement of pages for every sort of client, additionally the bother of keeping up those 2 sets throughout the years, attempting to keep them in a state of harmony.

Beating the Mobile Device's Defaults: Viewport

With the end goal of this article, to abstain from qualifying all that I say, making things much more longwinded than it should be, I will utilize the accompanying shorthand. When I say either "desktop" or "PC" here, I mean a desktop or Portable PC, not a cell phone or tablet (despite the fact that the last two are really PCs as well). What's more, when I say a cell phone, a tablet with a little screen, and not a Portable PC (however the last is additionally versatile), without this shorthand, the article will be considerably more hard to peruse than it as of now is, with numerous sentences quite recently to clarify what I mean when I say these terms. I additionally tend to utilize "cell phone" synonymously with "cell phone" here, so that the article doesn't sound excessively tedious.

The programs of present day cell phones are composed with the information that sites are customarily intended for PC screens. All things considered, it adjusts by putting on a show to the site that it has a PC measured screen and scaling everything to fit in it. For instance, Safari on the iPhone 5 imagines that it has a screen width of 980 pixels of course, despite the fact that its genuine size is 320 pixels (in picture mode). So if you somehow happened to plan a site with a settled width of (say) 730 pixels, its whole width will fit into your cell phone's screen, despite the fact that the last isn't that wide. The program fulfills this by contracting your site so that everything turns out to be tiny. On the off chance that the client needs to peruse anything, they should zoom in the important bits. You can see this impact by heading off to the settled width demo page with your cell phone. That specific page has a settled width of 730 pixels, and is intentionally outlined not to adjust to your utilization of a cell phone.

Since this default of imagining that the gadget has a width of 980 pixels and consequently scaling content thrashings our endeavor to physically make an agreeable ordeal for versatile clients, we need to abrogate it before we can do anything important. To do this, add the accompanying HTML tag to the area of your website page:

<meta name="viewport" content="width=device-width, initial-scale=1">

The viewport meta tag above educates the program to utilize the real gadget width with a scaling element of 1. That is, it is not to imagine that it has some other width, nor is it to scale the substance with the goal that it fits into the current window. Everything is to be utilized as-seems to be. This guideline makes versatile programs act precisely like their desktop partner.

The Key that Unlocks a Responsive Design in CSS: Media Queries

Since we have the cell phone's program to abstain from resizing things in the face of our good faith, we need to adjust to its little screen physically. While this appears like a stage in reverse, it really permits us to get things done in a more suitable manner than the telephone's robotized office: for instance, we can resize the things that can be resized (e.g. pictures), while taking off alone others that shouldn't be resized (like the words). To make space for this, we can send components that are not all that significant to the base of the screen. For instance, if you somehow managed to peruse any article on, including this one, on a cell phone, you will find that my route menu (i.e. the rundown of catches) that is ordinarily in the left section in a desktop program, is situated at the base of the page on a cell phone. I assumed that since the client is on this page, his/her basic role is to peruse the article. Accordingly, I put the article at the top with the goal that guests can get to it promptly.

To fulfill enchantment like this, we require some approach to identify the screen estimate. Current programs give this office as a "media inquiry".

A media inquiry in a template looks something like this:

@media screen and (max-width: 320px) { 
    /* CSS for mobile screens that are 320 pixels or less will be placed in this segment */ 

Any CSS placed inside the wavy sections of that above media query will be applied only to mobile screens which have maximum width of 320 pixels. You are, obviously, not confined to testing for a width of 320 pixels. The last is simply a figure I picked for this case. You can test for min-width and max-width of any size. You can even test for scope of sizes too, for example, in the accompanying code.

@media screen and (min-width: 320px) and (max-width: 640px) { 
    /*CSS for mobile screens that are no less than 320 pixels wide yet not exactly or equivalent to 640 pixels wide */ 

CSS decides that are not encased inside a "@media" segment apply to everybody. What's more, code that is encased inside a particular "@media" area might be utilized when the states of the inquiry are met. In the event that you have numerous conditions that must be met at the same time, interface them with "and" as in the illustrations given. You can have various media question obstructs, each of which may be connected when the conditions for that piece are met.

/* code that is here, until the main @media piece, will apply to any screen measure */
#some-div {
    width: 960px;

@media screen and (max-width: 320px) {
    /* becomes effective for screens not exactly or equivalent to 320 pixels */
    #some-div {
        width: 300px;

@media screen and (min-width: 321px) and (max-width: 480px) {
    /* becomes effective for screens in the vicinity of 321 and 480 pixels (comprehensive) */
    #some-div {
        width: 450px;

@media screen and (min-width: 481px) {
    /* becomes effective for screens bigger than or equivalent to 481 pixels */
    #somethingorother {
        width: 600px;

/* code that is here will apply to any screen estimate */

Take note of that the above is only a case intended to delineate the utilization of various pieces of media inquiries. My decision of the numbers utilized there is self-assertive, so don't invest energy pondering them.

You can likewise put your media inquiries in the <link> component itself, so that a whole template is just connected when that specific arrangement of conditions is met. For instance, the accompanying burdens 3 templates, one as far as anyone knows for cell phones in representation mode, another for their scene mode, and the last for desktop and PCs.

<link rel="stylesheet" type="text/css" media="screen and (min-width: 481px)" href="desktop-screen.css">

<link rel="stylesheet" type="text/css" media="screen and (max-width: 360px)" href="responsive-portrait-screen.css">

<link rel="stylesheet" type="text/css" media="screen and (min-width: 361px) and (max-width: 480px)" href="responsive-landscape-screen.css">

This permits you to neatly isolate your code for various screen resolutions into various records, if that is the thing that you need. At the end of the day, take note of that the purpose of the case above is to show the utilization of media inquiries in <link> labels. The numbers are discretionarily chosen.

Media Queries Compatibility with Browsers

The media inquiries office that permits us to test for screen size is a latecomer to the web program scene. That is to state, CSS had as of now existed for quite a long time before the standard incorporated the way to restrictively apply certain tenets to certain screen sizes. All things considered, exceptionally old programs don't bolster these elements.

Where cell phones are worried, the extent that I know, media inquiries are just bolstered on Android programs starting with rendition 2.1, on iPhone’s Safari 3.2 or more, Blackberry 7 and later, Opera Mobile 12 and later, Opera Mini 8, and Internet Explorer ("IE") versatile 10 or more.

On the desktop/portable workstation programs front, bolster seems to have begun with IE 9, Firefox 3.5, Safari 4 and Chrome 4. Microsoft Edge, since it was initially in view of IE 11's code, has dependably had media inquiries bolster.

In perspective of the above, how safe is it to utilize media questions on your site?

A considerable measure relies on upon your site's socioeconomics. For instance, if your site has many individuals utilizing telephones with IE versatile 9 and prior, you will likely need to bolster them.

This is not incomprehensible, since early forms of IE permit the utilization of restrictive remarks, where you can incorporate guidelines that may be rendered by them and not different programs. All things considered, it's conceivable to distinguish those programs without falling back on media inquiries.

On the other hand, you can utilize JavaScript to distinguish the screen measure and modify your template in like manner. There are even free JavaScript drifting around the Internet that execute media questions on early IE forms, in spite of the fact that I have not attempted any of them and hence can't vouch for them.

On the off chance that your site has not very many guests utilizing such old portable programs, then you need to choose whether or not you need to try making an answer exceptionally for them. You may find that the time and exertion you have to use is unbalanced to the quantity of individuals that really advantage from it. Also, those numbers will just diminishing with time. In that capacity, you may need to simply give such clients a chance to see your site utilizing the default template (which was what everybody would have seen in any case, before you all of a sudden chose to make a portable inviting one).


Recent Posts

Explore the recent blog posts about our Responsive Checker Tool and other Online Tools and get to know the latest information and latest technology trends from the whole world.

Best JSON formatter and JSON validator
  • 15 Jun

What is JSON? JSON stands for JavaScript Object Notation. JSON is a lightweight and data interchange format which is used to change the content into readable and writeable formats for humans. The JSON formatter formats the given JSON string into the formatted form with different colors. It has also colored format. JSON string output can be understood and can be read easily... Read More

Test your website on different mobile phones
  • 11 Jun

What is a mobile friendly website? It is a type of website which displays properly and perfectly on small screen devices such as: Android phones, iPhones, iPads, tablets, mini laptops etc. A mobile friendly website has many features like, it loads faster than non-mobile friendly website as many irrelevant sections are being hidden. A user can easily read the content on a mobile... Read More

How to generate an HTML sitemap
  • 06 May

What is a sitemap? "Sitemap is a type of file which consists of a huge number of URLs or LINKS of all web pages of your website." Working of a sitemap: Work of a sitemap is to provide a file of URLs of all pages of your website for Google and other search engines. In this manner, a user can easily navigate to... Read More