Viewport is a necessary tag to display the HTML page correctly

2023-10-21 13:45:04
2023-10-21 13:45:04
Viewport – this is the screen that the user actually sees. A simple description of this parameter is measured by the size of the diagonal. In practice, the description of the visible area of the monitor page is a set of parameters, including diagonal, aspect ratio, and the number of pixels per unit area.
Obviously, small smartphones have the smallest diagonal, and large monitors have the largest. However, the current era was preceded by a time of less developed technology, so the variety of gadgets was less. The screen parameters did not differ significantly and there was no need to enter a new parameter in the page header. The state of the art allowed the use of both flexible and fixed markings. In fact, what difference does it make if the sites are still viewed under approximately the same conditions?
But the creation of a mobile device brought novelty to this issue. The gadget already has a wide range of parameters, including pixel resolution. Thus, the screen visibility area has become more variable, which posed a challenge for developers to adapt the site page to the device. Viewport HTML was created later. Initially, the issue was resolved by making changes to the site design file.
CSS3 – Today almost all devices support this specification. But it also has drawbacks. Due to the variety of screen resolutions, responsiveness has to be created for each parameter separately. Two smartphones may have an identical diagonal, but the number of dots per unit area may differ by a factor of two. This is exactly the difference that can be observed between Apple products.
iPhone 3 ________ 320 - 480
iPhone 4 ________640 - 960
Smartphone models from the same manufacturer differ in the number of dots on the screen by a factor of two. Inaccurate determination of font sizes and block outlines resulted in inconvenient horizontal scrolling. This caused great discomfort for Internet users.
Meta Viewport is a tool that takes into account the shortcomings of the CSS3 design file. Vertical scrolling is considered natural for any page. It is horizontal scrolling that causes inconvenience. The text is difficult to read if you have to constantly move it to the sides. This defect occurs precisely because of the inaccuracy in determining the width of the page. And the user can set the screen horizontally.
The parameter is added in the header of the HTML page. The example specifies two parameters: tag name and width. Viewport Meta Tag - this line allows you to set the exact width of the screen. Thanks to this, the text block completely covers the width of the screen.
Below is a simple example of a line that will save the situation. Tag options have many more options, but this is what the simple spelling looks like.
Option 1 p>
meta name=”viewport” content=”width=device-width, initial-scale=1.0”
Option 2 p>
meta name=”viewport” content=”width=device-width, initial-scale=1” /
Viewport width The parameter tells the browser exactly how to process the page. In the above examples, we could notice a difference in defining the screen width.
width=680
width=device-width, initial-scale=1.0
The first example sets a fixed monitor screen width. This can be a positive integer between 200 and 1000 points. The second example adapts the page content to different screens.
height= 680
height= device-height, initial-scale=1.0
Viewport height The first line specifies the screen height, an integer from 233 to 1000 pixels.
The list of parameters indicates the main scaling methods. Important note - in practice, it is recommended to use only the first parameter, since the rest will make it difficult for the user to view the page and reduce the accessibility of the content.
Head – This is the section of every HTML page that should contain the Viewport parameter. Please note that some browsers do not honor the page adaptation tag.
For such cases, old tags are used. Popular website builders such as WordPress do not automatically assign customization options. To resolve the issue, you need to use a special plugin. But this does not mean that the Viewport meta tag can not be written in the code. In this case, the search engine will take this into account as an error. Therefore, an indication of the scale must be written on the HTML page.
The absence of a Viewport tag is considered an error by search engines. Although website builders do not automatically write this line, and some browsers do not yet take it into account, care must be taken to ensure that the page displays this line. Also, you should not treat the issue formally. A lack of width and scaling parameters, or incorrectly written code will also lead to an error and poor website ranking in search results.