Adaptation of the site for mobile devices: step by step instructions. Mobile version of the site

Table of contents:

Adaptation of the site for mobile devices: step by step instructions. Mobile version of the site
Adaptation of the site for mobile devices: step by step instructions. Mobile version of the site

Mobile adaptation of the site is becoming more and more popular due to the increase in the number of smartphones and tablets. What does she represent? What benefits does it provide? This issue is especially relevant for owners of online stores, websites of various service companies, blogs and popular forums. How can a website be adapted for mobile devices? Here is a small list of issues that we will consider as part of the article.

General information

website adaptation for mobile devices
website adaptation for mobile devices

So first let's look at what responsive design is. This is the name of a configuration in which the same HTML code is sent to all devices, but the sizes of the elements are adjusted using CSS. Various search robots are able to recognize such sites, provided that the pages and resources are open for crawling. The meta name="viewport" tag is used to indicate to browsers that this is possible. What is the adaptation of the site for mobile devices?

Consider the tag

So, you need to take care of the meta name="viewport" tag. Why is he? It is in himcontains instructions for the browser on how to resize and scale the page to fit the screen width of the device from which the site is viewed. If you don't add this small element, the desktop page will be displayed by default. But in doing so, mobile browsers will try to optimize the content, which will result in larger fonts, scalable content, or displaying some of the content that fits on the screen. Is it nice? No, the mobile version of the site in this case will only cause a negative perception. After all, the fonts will be disproportionate, you will have to scroll the page and perform a number of other actions, which, although they are secondary, are still tedious. You can check the adaptation of the site for mobile devices using a smartphone, tablet or special services and programs. Of course, the first two options are more preferable, but if you need a thorough analysis from the perspective of various devices and save time, then the latter will do.

What are the benefits of adapting a site for mobile devices?

Mobile version of the site
Mobile version of the site

Using this approach allows:

  1. Users share content when it has one address.
  2. Search engine algorithms get exact page parameters, no confusion with different versions.
  3. Reduce the chance of errors.
  4. Shorten load times by eliminating the need for reindexing.
  5. Save resources.

Also,It is easier to create an adaptive page than several variants of one thing. Adapting a site for mobile devices (it is quite possible to do it yourself) is not something difficult, it is enough to know JavaScript and be able to work with cascading style sheets (CSS) and images. There are many approaches to accomplishing the task. The article will consider the three most popular options:

  1. Focusing on JavaScript.
  2. Combination.
  3. Dynamic use of JavaScript.

Let's take a closer look at them.

Customization using JavaScript

mobile adaptation of the site
mobile adaptation of the site

In this case, one content is used. And with the help of JavaScript, formatting changes with the mechanism of the page. Everything in such cases depends on the platform. This algorithm is similar to Cascading Style Sheet media queries. Let's consider a small example of work in practice. So, we have a page with HTML code in which the element is placed. When requested, the same data will be transmitted. But when it comes to processing, the characteristics of the device will have a significant impact on this. And as a result, the page formatting will change. An example is the situation with an image that will be optimized for viewing on smartphones and tablets, and not on computers. An important advantage of this option is that the implementation is automatically recognized by the computer. In addition, you do not need to acquire a special header, since there is no dynamicdisplay content.


In this case, the adaptation of the site for mobile devices is used due to the combination of JavaScript capabilities and server functions. What does the general scheme look like? The user accesses the site from a specific device. JavaScript receives information about what it used and passes it to the server. The necessary code is generated there, which is subsequently sent to the device. Moreover, this information is stored in cookies. And on a subsequent visit, the server reads data from them. A feature of this approach is the ability to use different versions of the HTML code. True, for correct operation, you need to take care of the presence of the Vary: User-agent header. The mobile version of the site in this case requires a little more work.

Dynamic JavaScript and other options

plugin to adapt the site for mobile devices
plugin to adapt the site for mobile devices

This assumes that the same code will be provided with a specific element, which points to an external file whose content varies depending on which agent is being used. That is, we will have a dynamic page in front of us. How is it implemented? Many people use the same Vary: User-agent for this. And when working with pages, information will also be updated in real time, which is certainly very good. There is much more to be said about theory. How not to remember divas (), with the help of which you can literally “juggle” the appearance of the site and many other different things. But wewondering how to do it!

Preparing for implementation

website adaptation for mobile devices
website adaptation for mobile devices

It should be noted that there are two approaches to the task of creating a responsive website:

  1. Manual.
  2. Automatic.

Initially, you need to choose which path to take. So, a plugin for adapting a site for mobile devices will help you do all the work quickly. But only if everything is created according to certain, clearly regulated rules. If the resource was created according to them, the program for adapting the site to a mobile device should do everything without problems. Due to such restrictions, and sometimes other moments and the lack of full creative freedom, the majority opts for manual settings. And although the programs help to get an attractive version of the resource in just a few minutes, they still have certain disadvantages.

Flexible layout

check site adaptation for mobile devices
check site adaptation for mobile devices

In order for us to get a literal "candy", you need to use only relative units of measurement. In practice, all fonts are em-sized, and the size of the elements is indicated as a percentage. Although you can periodically (if you really want to) use px, it’s better to do without them. When specifying width (width) or height, you should not use a certain fixed number like 1080, 1260 or 768, but a percentage. As an example - width: 90%. You can do 80%, 99%, and 100%. It all depends on the desire of the master. But what about the text that is displayed on a certain element? For such a case, there is one very good formula: the font width is divided by the same indicator of the background component, and we get our claim result. Sometimes it happens that the numbers can be very long. For example, the standard is 1260. And users who have a screen width of 780 enter. When dividing, we get a very long number. Does it need to be rounded up? Well, the situation here is complicated. Many do not recommend doing this. It is better to look at the situation and evaluate how important accuracy is. You can, for example, set that only two, three, four or ten decimal places are taken into account. Believe me, this is a simple job, this adaptation of the site for mobile devices. CSS, if it contains entries without errors, will be able to play everything.

Flexible font, images and media queries

By default, the font size in browsers is set to 16 px. But, as mentioned earlier, such an approach is highly undesirable for us. What to do in this case? Then the desired value is divided by the base. Consider a couple of examples:

  1. 16/16=1 em.
  2. 18/16=1, 125 em.

The result must be written to font-size, adding a colon after it. True, if these values are later included somewhere else, it should be borne in mind that it will be displayed exactly the value we entered.

And now for the images. Everything can be entered either in their attributes, or in a cascading tablestyling with max-width. Do not forget that the size is indicated in percent! And a few more words about media queries. They can be used in cases where it is necessary to set certain conditions. For example, if the screen width is less than 1260px, the rules nested in the media query will apply. What can they do? If we have a beautiful background image that should be displayed in full, and the user has a small screen, in such cases it can be written to remove it. In some ways, media queries are like an if construct. But their feature is a very big … individuality. They can record all the changes that need to be made when working with browsers of certain sizes.


website adaptation software for mobile devices
website adaptation software for mobile devices

The number of mobile devices and the people who use them is constantly growing. Therefore, it is highly desirable that even the smallest details, not to mention the concepts, be worked out in the site layout before starting its development. After all, it is necessary to ensure that users accessing the site from phones do not download data that will not be displayed to them. Why? Well, this is elementary - so as not to slow down the loading of pages. And it's better to make sure that the data is loaded in small portions, and the site itself works quickly and efficiently.

Popular topic

Editor's choice

  • Let's build iOs apps! Overview of programs, instructions, recommendations
    Let's build iOs apps! Overview of programs, instructions, recommendations

    Today more and more people are starting to dive into the world of IT. A fairly common industry is the creation of various kinds of mobile applications. Quite a lot of different games and programs have already been developed for Android. It is because of this that many developers have begun to move to the iOS platform. This is not a very crowded industry where you can find a lot of clients and make quite a lot of money

  • Moving WordPress to another hosting: features, procedure
    Moving WordPress to another hosting: features, procedure

    Today, every person who has his own website on the Internet may face the problem that he will need to transfer the site to another hosting. There can be many different reasons for this. Of course, the most common of them is dissatisfaction with the services provided. If you can't take it anymore, then you need to act. This is a rather long procedure. If you do everything step by step, you can safely transfer the site, and not redo everything several times

  • How to pass on the rights in "SAMP RP"?
    How to pass on the rights in "SAMP RP"?

    Every person who plays online games is trying to upgrade his character and achieve many interesting things. Users who prefer SAMP try to get a driver's license even from the first level. Experienced players may not take the exam, but simply go to the instructor and buy rights from him. Of course, it will be somewhat more expensive, but this way you can save your time. How to pass on the rights to "SAMP"? Let's review this

  • How to turn off the camera on a laptop? 3 easy ways
    How to turn off the camera on a laptop? 3 easy ways

    Today, hacking has begun to actively develop in the world of information technology. An experienced hacker can get into almost any computer and get the user's information, provided, of course, the laptop is connected to the network. Recently, users have been complaining that their webcam turns on by itself. This way hackers can see where you are and what you are doing. In the future, this information can be used in completely different ways, up to the fact that you become a star on YouTube

  • Shared AppStore Account Features
    Shared AppStore Account Features

    A shared App Store account has many features. It allows users to install games and applications, as well as watch movies in high definition. Shared accounts give official access to app and game downloads for Apple devices (iPhone, iPad, iPod Touch)