What's the reason behind the larger font size on a site that is not responsive?

I find it puzzling why the font size appears large on small screens for a non-responsive site (without the

<meta name="viewport" content="width=device-width, initial-scale=1.0">
tag). I prefer the font to be smaller and allow for zooming.

Here is the HTML code for two columns with text:

<div class="s">
    <div>
        <h2>...</h2>
        <p>..</p>
    </div>
    <div>
        <h2>...</h2>
        <p>...</p>
    </div>
</div>

And here is the corresponding CSS:

body {
    font: 100%/1.5 Tahoma, Geneva, sans-serif;
}

.s {
    display: flex;
    margin: 50px auto;
    width: 1000px;
}

.s div {
    background: #eee;
    flex: 1 1 100%;
}

You can view the demo here. Feel free to test it using F12 or Ctrl+Shift+M (device mode) in Chrome.

Another demo with scalable text in the <body> section can be found here.

https://i.sstatic.net/hE0nc.png

I aim to have all the text styled like the one highlighted within the red border in the image above.

Answer №1

The reason for this effect is due to the "Mobile Text Size Adjustment" algorithms implemented by browsers. More details can be found here. When not using responsive mode, the browser attempts to adjust text in paragraphs and headings.

Although there is a CSS rule called text-size-adjust to control this behavior, it doesn't function properly in most browsers.

Fortunately, a workaround has been discovered by someone:

p {
  max-height: 5000em;
}

This sets the max-height property to disable the "Mobile Text Size Adjustment" algorithms, resulting in all paragraphs being zoomed out in this scenario.

Answer №2

Your fixed width of 1000px is causing the browser to display text in the div larger. The browser needs to fit all the text within the set width, which is why it increases the font-size. If you were to set the width to 100%, everything would work correctly!

.s {
    width: 100%;
}
<div class="s">
    <div>
        <h2>Test one</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat ex quis perspiciatis commodi reiciendis tempore autem vel provident alias cupiditate accusamus dolores hic aperiam, blanditiis quia animi, suscipit sunt mollitia.</p>
        Text without &lt;p&gt;
    </div>
    <div>
        <h2>Test two</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat ex quis perspiciatis commodi reiciendis tempore autem vel provident alias cupiditate accusamus dolores hic aperiam, blanditiis quia animi, suscipit sunt mollitia.</p>
        Text without &lt;p&gt;
    </div>
</div>

Text in body.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The modal appears on the screen prior to the content being shown

While attempting to render a bootstrap modal with content from a REST call, I am encountering an issue where the modal appears before the content has finished populating. The modal is triggered by a button click event. If I click the button again after wa ...

Top strategy for incorporating text into a logo design

My goal is to create a logo similar to the image below, with the black rectangle as an image and the text as real text. I have tried the code below (also available on jsfiddle http://jsfiddle.net/ueZ2H/ and it seems to be working. However, I am unsure if t ...

What steps can be taken to create a seamless navigation experience that effectively emphasizes the user's current location?

Is there a way to dynamically add the "current" class to the navigation menu based on the user's current location on the page? This would make it easier for users to see which section of the site they are viewing as they scroll through. Check out this ...

Design a background image that is optimized for both high-resolution retina displays and standard non-ret

Scenario I am working on a web page where I want the background image to be fixed, covering the entire screen or window (excluding tablets and smartphones). The background image has been created using ImageShack. Everything is running smoothly so far. T ...

What is the process for linking an Android application to a particular class within an HTML code?

I have a unique idea for an Android app dedicated to my university. In this app, users/students will be able to enter their student code and password on the login page. By clicking "log in," the app will redirect them to their personalized portal on the un ...

How to properly align the title of a mobile modal in Bootstrap 4

I'm new to using bootstrap for my website, specifically under bootstrap 4. I have a modal that is left aligned on PC, which is great. However, I want the title to appear at the top of the div on mobile for better readability. Right now it looks very ...

Click anywhere on the body to conceal this element

I am currently working on a website where I have implemented a hidden menu that is functioning correctly. However, I want to make it so that when the menu is visible, users can click anywhere on the body to hide it. Unfortunately, my current code is not w ...

Issue with Bootstrap tab display of content

I'm having trouble with the tabs in my page. When I click on each tab, the content doesn't display correctly. Here is my code: <div class="w470px exam" style="border: 1px solid #ddd; margin-top: 30px;"> <ul id="myTab" class="nav nav ...

The functionality of Bootstrap v4 push and pull grid classes seems to be failing to meet expectations

In the process of developing a web application, I am using Bootstrap v4 (alpha 3) to create a responsive layout. Most elements are working well, however, I am facing difficulties rearranging my cards using the push and pull classes in Bootstrap. The intend ...

:hover doesn't fully implement background color on list items

When I hover over the dropdown items in my navigation menu, I would like the background color to change for the entire list item. Currently, the background color only changes when hovering over the text itself and reverts back to its original color when mo ...

Accessing the id within both objects is proving to be a challenge for me

I'm facing an issue with accessing and posting values of the id within Position and Department in Angular. It seems like the id is not being accessed correctly. addEmployee.model.ts export class AddEmployee { Position: { id: string; }; De ...

Adding Space Before Bullet Points in HTML: A Quick Guide

Is there a way to add space before bullet points? My requirements are as follows: This is paragraph 1 The first text line The second text line This is paragraph 2 The first text line The second text line I would greatly appreciate any ...

What are some creative ways to animate a highlight effect on a CSS

I'm struggling to implement a sliding underline effect for my top navigation bar on hover. I've tried using transitions and keyframes, but so far it's not working as expected. My current attempt only triggers the effect on the parent elemen ...

Setting the start date to the following day at midnight on Bootstrap DatePicker - how can it be done?

Struggling to utilize the Bootstrap date picker, and seeking a way for users to select dates starting from the next day on the calendar. Is there a method to set the start date as (data-date-start-date="12AM next day") instead of (data-date-start-date="+1 ...

Challenges with Bootstrap

In my journey of developing a web-based audio player, I find myself venturing into the world of Bootstrap for the first time. As it stands, here's how my player looks: View Player Below is a snippet of my source code: <!DOCTYPE html> <html ...

Using ORDER BY RAND() on Internet Explorer consistently returns the same row

I am using a JavaScript function called by a button to perform an AJAX request to a PHP file. This PHP file connects to the database and echoes a random row from the database. The following PHP code is responsible for this: $value = $db->get_row("SELEC ...

display the designated image as a priority

I am designing a loading screen for my website that includes the loading of multiple images, scripts, and other elements. While the HTML and CSS part is working well, I need to ensure that the "loading..." image is loaded before anything else on the page. ...

The page displays a pair of vertical scrolling bars

My webpage is displaying two scrollbars on the right side of the browser, but I only want one scrollbar. Can anyone help me fix this issue? Thank you for any assistance. html, body { margin: 0; background-image: url("images/background.png"); ...

Configure the asp.net page to display only once

Is there a way to configure an asp.net page to only display once? I want to ensure that if a user logs in again, they won't see the page again. ...

How can I open a PDF file on the frontend using the Django framework?

I am attempting to extract content from a PDF file using the Django framework. Here is what I have tried so far: def upload(request): try: if request.method == 'POST': if request.FILES['document'].name.split ...