Is it advisable to set the html root at 62.5% when using rem units in CSS? Does this imply that the default font size of browsers is 16px?

During a discussion with a group, I mentioned the 62.5% trick for scalability (setting 62.5% as font size in root and using rem units throughout CSS for easier scalability when users change default browser font size) and their arguments were as follows:

"A browser can set any font size it wants, so if you want to ensure a specific size, you need to specify it in CSS."

"I believe REM is unnecessary for setting a certain size in styles. Using custom properties like --unit: 10px; allows you to reuse the size without setting it as the font size of the HTML tag. Don't base your CSS on assumptions about browser stylesheets; set what you know you want, such as 10px."

"I personally find REM to be almost useless. Some people complicate things with complex formulas and mental math instead of simply setting the desired size. For example, if I want a heading to be 24px, I just set the font-size to 24px directly, rather than setting it to 10px and calculating multiples."

Additionally, there was a question raised about articles using rem where changing the font size in body within media queries affects rem values. The common belief was that only font sizes should impact rem units - is this accurate?

Answer №1

If you prioritize accessibility in your project (which you should), then opting for relative methods for font sizing, as suggested, is the ideal decision. This is because most browsers default to a computed value of 16px for display size.

According to MDN, defining font sizes in px is not accessible since users may not be able to adjust the font size in certain browsers. Individuals with visual impairments may need to set a larger font size than what is chosen by web designers. To promote inclusive design, it is recommended to avoid using pixel-based font sizes.

To demonstrate the impact, consider adjusting your browser's font size preference to something larger, like in Chrome. You will notice that fonts set in px do not conform to your preferences, forcing users to zoom the page. Constantly zooming in can become frustrating and should not be imposed on anyone.

The 62.5% method simplifies the process for developers to understand the relationships between pixel values and em or rem units - for instance, 2.7rem equals 27px is easier to grasp than 27 / 16 = 1.6875rem. While there are other approaches, the 62.5% choice stands out. Check out this CSS-Tricks article for an insightful discussion: Accessible Font-Sizing Explained

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

Create a URL hyperlink using javascript

I am looking to create a link to a page that updates its URL daily. The main URL is where X represents the day of the month. For example, for today, July 20th, the link should read: In my JavaScript section, I currently have code that retrieves the cur ...

"Generate a series of dropdown menus with choices using either jQuery or AngularJS from a JSON dataset

I'm in need of assistance. I want to generate select dropdowns dynamically based on data retrieved from my REST API, which is in JSON format. How can I dynamically inject these selects into my HTML? Below is an example data structure: JSON data fetch ...

Do CSS Stylesheets load asynchronously?

Is there a difference in how stylesheets are loaded via the link tag - asynchronously or synchronously? In my design, I have two stylesheets: mura.css and typography.css. They are loaded within the head section of the page, with typography.css being load ...

Tips for correcting the sentence that extends beyond the boundaries of the Material UI box

Utilizing Material UI for my project... I am trying to contain the text within a box but facing issues with responsiveness as the text is overflowing outside of the box. Note: I have attempted various solutions from Stack Overflow such as word-wrap, max- ...

Trigger animation once you've scrolled past a designated point in the document

I created a count-up counter animation using JavaScript, but the issue is that the counter starts animating as soon as I refresh the page regardless of where I am on the page or if the counter is even visible. I would like the counter to only start workin ...

url-resettable form

Currently, I am working on an HTML form that includes selectable values. My goal is to have the page load a specific URL when a value is selected while also resetting the form back to its default state (highlighting the "selected" code). Individually, I c ...

The browser is unable to display an image file that contains the special character "%" in its name

I have an image file named 'a%1.jpg' that is not appearing in the browser. The code for my image tag is <img src="a%1.jpg" id="Image1" />. Is there a way to properly render the image using escape sequences? ...

Android WebView does not support rendering Persian fonts

I am having an issue with applying a Persian font to my html content, which contains both Persian and English text. The CSS is correctly applied except for the font itself. In the CSS, I have defined the font-face like so: @font-face{ font-family ...

Tips on switching the positions of two links when they are clicked using jQuery

<div class="applications-wrapper"> <div class="eye" id="onetwo"><a class="fa fa-eye" href="#"></a></div> <div class="bar" id="twothree"><a class="fa fa-bars" href="#"></a></div> </div> My ...

Targeting images within content in Wordpress

In my custom Wordpress theme, specifically on the single-post page where individual posts are displayed, I have implemented the following code: <article id="post-<?php the_ID(); ?>"<?php post_class('col-md-12'); ?>> <div cla ...

What steps can be taken to avoid generating a fresh instance of a component when rearranging them?

On the desktop version, the component is structured like this: <div className="parent-comp"> <div id="child-1" /> <div id="child-2" /> </div> However, on the mobile version, it switches to: ...

Tips for aligning text alongside ons-select elements

I am working with the following HTML snippet: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://unpkg.com/onsenui/css/onsenui.css"> <link rel="stylesheet" href="https://u ...

What are some possible applications for leveraging the HTML5 <link rel> attribute duo of stylesheet and next?

The specification for HTML5 emphasizes the handling of each link created within a link element as separate entities. This means that multiple link elements with `rel="stylesheet"` are treated independently, considering them as distinct external resources a ...

Only the Backdrop is triggered by Bootstrap Modal

I've been struggling to figure out why the bootstrap modal is not showing up after hours of troubleshooting. All the files and syntax seem correct, as I have compared them with another working site where the modal functions perfectly. I even disabled ...

View a pink map on Openlayers 2 using an iPhone

I am currently working on a project where I am trying to track my location using my smartphone and display it on a map. To achieve this, I am utilizing openlayers 2. However, I am encountering an issue. When I implement the code below in a Chrome Browser ...

The mdb navigation bar seems to constantly change its height

Having an issue with the height of my mdb navbar in my Angular app. It randomly flips to a larger size when reloading the page, but returns to normal when I open the developer console in Chrome. Two screenshots show the correct display and the incorrect i ...

Styling <Link> component with styled-components: A step-by-step guide

Utilizing the Link component from @material-ui/core/Link in my TypeScript code was initially successful: <Link href="#" variant="body2"> Forgot? </Link> However, I am exploring the transition to styled-components located in a separate file. ...

Guide on showcasing an icon adjacent to the input fields once they have been validated successfully with the help of jquery plugins

I am struggling with the code below which is supposed to validate the SubmitForm when the button is clicked. It successfully changes the textboxes to red and displays an error message with a symbol if validation fails. However, I am wondering how I can sho ...

Show the entire background photo

Below is the CSS code I am currently using within an inline style: <div class="home-hero" style="background-image: url(https://dummyimage.com/300); background-position: 100% center; background-repeat: no-repeat; background-size: cover; height: 100%; wi ...

Issue with the functionality of max-height in a CSS grid container

Update: After receiving clarification from @onkar-ruikar, I realized that my original problem was quite misunderstood. While I still haven't figured out how to properly handle the cyclic dependencies issue, I decided to address it separately. As a res ...