Make sure the font size on your iPhone matches the font size on other web browsers

Once upon a time, I came across an insightful article detailing a method to size text using CSS that is compatible with multiple browsers. The approach outlined in the article includes:

body {
    font-size:100%;
    line-height:1.125em; /* 16×1.125=18 */
}
.bodytext p {
    font-size:0.875em; /* 16x.875=14 */
}
.sidenote {
    font-size:0.75em; /* 16x0.75=12 */
}

This technique works effectively on most browsers, except for Safari on the iPhone, which tends to enlarge specific text segments. Is there a way to prevent this inconsistency from occurring?

Typically, adding -webkit-text-size-adjust: none; would address the issue by stopping the iPhone from enlarging text sizes. However, after reading this article, it appears that this approach restricts users from zooming in on text in any Safari browser - posing a different challenge. While aware of a CSS-only solution, pinpointing it has been elusive. My goal is to determine the correct method of setting font sizes to ensure consistent display across all browsers, including iPhones.

Update: As an illustration, when viewing this site on an iPhone, you'll observe that the paragraph text appears significantly larger than other content on the page. Why does this anomaly occur and how can one preemptively identify such discrepancies within the code?

Answer №1

Have you found a technique that works well for you but has one drawback?

Your strategy is effective on most browsers except Safari on the iPhone, which tends to enlarge certain text portions. Is there a way to prevent this from occurring?

..

Typically, adding -webkit-text-size-adjust: none; would stop the iPhone from enlarging text, but I recently stumbled upon this article, highlighting that it restricts users from zooming in on text across all Safari browsers - a clear issue. I am aware of a CSS-only solution, but cannot locate it.

Take a look at style.css from

/* Prevent mobile zooming while remain desktop zooming.
   github.com/shichuan/mobile-html5-boilerplate/issues/closed#issue/14
 */
body {
    -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: none;
}

This seems to be exactly what you need, especially after reading the comment in the link:

It might be wise to set -webkit-text-size-adjust to 100% instead of none. Using none hinders font zooming in desktop WebKit browsers, posing an accessibility concern. Mobile Safari's default value exceeds 100%, leading to larger text - setting it to 100% maintains correct sizing on mobile while allowing zooming on desktop.

Answer №2

In my opinion, it is preferable to utilize pixels instead of points when designing for both Macs and PCs. The way these two devices render points can differ significantly, whereas with pixels, the variations are generally minimal (although there may still be some subtle distinctions).

Furthermore, regarding line-height, discrepancies may exist between different browsers, such as Safari and Firefox on a Mac. In such cases, conditional styles for Internet Explorer or JavaScript solutions for adjusting Firefox's line-height can be employed.

Lastly, it is essential to note that certain fonts may appear differently across various browsers, necessitating thorough testing to ensure consistency.

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 appearance of an SVG image inside an absolutely positioned div varies between Firefox and Chrome

The web page I am working on can be found at the following link: This webpage consists of text and SVG images, with the hex bolts positioned over specific areas of the text. Achieving this effect requires absolute positioning within a relatively positione ...

Having trouble loading Three.js in JavaScript file using npm install?

I am encountering a problem when trying to include Three.js in my JavaScript file without using the HTML script element. The error message I receive is "Uncaught SyntaxError: Cannot use import statement outside a module". Although my Three.js code runs suc ...

What is the best way to create a responsive grid layout for my form using Bootstrap?

I have designed a form using bootstrap 5 with 1 row containing 4 columns (1 dropdown menu and 3 buttons). While it looks fine on my desktop, the problem arises when I view the page on a mobile device. The buttons shrink and remain on the same row instead o ...

Retrieve information from MongoDB and display it in an HTML table

I have some data that follows this structure: { "jobname" : "2018_09_27_test123_0", "totalcalls" : 1836.0, "success" : 3.0, "fail" : 1833.0, "failureReasons" : [ { "reason" : "Unavailable", "count" : 53 ...

What is the best way to get my loading screen div to cover the entirety of my screen, including all content beneath it?

In order to create a loading screen, I am utilizing PHP to dynamically load specific services for my website. I attempted to set the height of my wrapper div to 100% but it did not produce the desired results. After that, I experimented with setting the he ...

Finding the Right Spot to Edit HTML Code in Microsoft Dynamics CRM

Is it possible to change the width of a custom iframe in Microsoft Dynamics CRM that is currently set at 1900px? <div id="mainContainer" class="classname_here" style="max-width: 1900px"> I was able to change it to 100% using a browser extension. Ca ...

Tips for rearranging table columns using drag and drop in react js

I have been experimenting with various libraries to create a drag-and-drop feature for changing table columns order. Here is my current implementation: import React, { useState } from 'react'; import './list_de_tournees.css' const Table ...

Implementing multiple content changes in a span using javascript

Having an issue with a pause button where the icon should change on click between play and pause icons. Initially, the first click successfully changes the icon from a play arrow to a pause icon, but it only changes once. It seems like the else part of the ...

"Troubleshooting a Responsive Design Problem: Horizontal Scroll Bar Appears on Low Res

My website is experiencing an odd issue with responsiveness. When viewed on desktop resolution in Chrome, there is no horizontal scroll. However, when I resize the browser to lower resolutions (400px width and less), the horizontal scroll appears. It see ...

angular-ui-tab-scroll: Odd spacing between blocks and tabs, each separated individually

Greetings! I would like to express my gratitude for this wonderful library! However, I am encountering an unusual issue when trying to wrap a tabset with tabs that are included separately. This can be done either by adding individual tab elements manually ...

Adjust the size of bootstrap card titles to match up with the image on the page

I am facing an issue where the title of the second card is pushing the image down. Is there a way to dynamically resize the card title to align all the images properly? Any help would be appreciated. https://i.sstatic.net/PRRHl.png Bootstrap Card ...

What is the best way to increase the font size without resizing the parent input element?

Is there a way to increase the font size in this text box without enlarging the box itself? Any suggestions or advice would be appreciated! https://i.sstatic.net/91pon.jpg. Below is my CSS code for reference (the class of the form is 'box'). .bo ...

utilizing the data provided by a user in the "prompt" window within my HTML code

Looking to utilize user input from the prompt window. This is my custom JavaScript form: var answer; function load() { answer=prompt("what is your name?", "Write your name here"); return answer; } function hideNsee() { var HNS = docume ...

The accuracy of real-time visitor numbers in Google Analytics is often unreliable

My website uses Google Analytics to track the page chat.php. The code snippet is correctly placed on the page according to the documentation. Within this page, there is a Flash object that connects users to an IRC chat room. Currently, there are 50 unique ...

Finding all anchor tags in raw HTML using htmlagilitypack

My HTML document contains the following code snippet: string htmlData = "<!DOCTYPE html><html><Head></Head><body>&lt;div&gt;&lt;a target=\"_blank\" href=\"http://blender.palmbeachschools.org/GetFile ...

Something strange happening with the HTML received after making a jQuery AJAX request

My PHP form handler script echoes out some HTML, which is called by my AJAX call. Below is the jQuery code for this AJAX call: $(function() { $('#file').bind("change", function() { var formData = new FormData(); //loop to add ...

What is causing the colored SVG to appear lighter than the intended color after using a mask to recolor it?

I have a project using VueJS where I am trying to change the color of SVGs by looping through them and using mask and rect tags. However, I am noticing that as the icon index increases, the color of the icon becomes lighter. What could be causing this issu ...

Experiencing problem with hover:after effect on Internet Explorer 8

I've been working on incorporating the CSS effect found on this website: Everything seems to be functioning properly except for the fix provided for IE8. I added some conditional code so that the fix is only applied to <= IE8, and as a result didn ...

"Performing a single ASIHTTPRequest in iOS results in multiple responses being received

I am facing an issue with ASIHTTPRequest in my iOS project. Occasionally, when I initiate a request, it receives multiple responses. Here is how I start the request: [request addRequestHeader:@"User-Agent" value:@"ASIHTTPRequest"]; [request addRequestH ...

Unable to set items as sticky within mat-tabs

Is there a way to make my image stick in place using the following CSS code? position: -webkit-sticky; position: sticky; top: 1px; I have tried implementing it but haven't been successful. HTML: <mat-tab-group class="user-tabs" (selectedTa ...