Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Text size issue on mobile

Can someone explain why perceived text size and wrapping change when adding the commented line into the body, below?

To clarify, I want to understand what the layout mechanism is doing in the problem case. I’m not looking for a solution, per se.

This is on mobile (it’s fine on desktop).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<!DOCTYPE html>
<html lang="en">
<head>
  <style>
    html { background-color: dimgray; }
    body {
      background-color: gray;
      font-family: monospace;
      width: 70ch;
    }
  </style>
</head>
<body>
  [== 60 char === === === === === === === === === === === ===]<br>
  [== 60 char === === === === === === === === === === === ===]<br>
  <!-- [== 60 char === === === === === === === === === === === ===] -->
</body>
</html>

At first, it renders as expected:

enter image description here

But if I un-comment the third body line, the text gets big and wraps:

enter image description here

Just a reminder, this is in mobile view:

enter image description here

>Solution :

The HTML <meta name="viewport"> tag sets the viewport properties of a webpage, influencing how it will be displayed on different devices. The width=device-width makes the width of the webpage follow the screen-width of the device, and initial-scale=1 sets the initial zoom level when the page is first loaded.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Reactive Viewport</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading