Setting the value of REM for all the properties in CSS

0 votes

I would like to use rem everywhere (read for all the possible properties) in my site. However, using the default rem - px conversion rate isn't quite intuitive :

10px = 0.625rem
12px = 0.75rem
14px = 0.875rem
16px = 1rem (base)
18px = 1.125rem
20px = 1.25rem
24px = 1.5rem
30px = 1.875rem
32px = 2rem

Therefore, I'm setting the font size to 1rem = 10px using the HTML syntax font-size: 62.5 percent ;. But what if I also want to set the margin, padding, border, etc. to that conversion rate?

Jun 21, 2022 in CSS by Edureka
• 13,620 points
2,054 views

1 answer to this question.

0 votes

We've covered this in comments, but essentially the answer is to set the base font size to 10px rather than 62.5%.

html { font-size: 10px; }

Now, all your rem values work from 1rem = 10px. which mean your calculations actually got a lot simpler.

  • 1.5rem = 15px
  • 2rem = 20px

...and so on.

Now margin: 1rem really does mean margin: 10px.

answered Jun 28, 2022 by Edureka
• 12,690 points

Related Questions In CSS

0 votes
0 answers

What are the implications of using "!important" in CSS?

I've been working on a website for ...READ MORE

Jul 18, 2022 in CSS by Edureka
• 13,620 points
421 views
0 votes
0 answers

highlighting the current page in a list of links using css / html

I am trying to amend a friend's ...READ MORE

Jul 25, 2022 in CSS by Edureka
• 13,620 points
602 views
0 votes
1 answer

What is the meaning of "cascading' in CSS??

Cascading simply implies that it may be ...READ MORE

answered Aug 3, 2022 in CSS by Tanishqa
• 1,170 points
799 views
0 votes
0 answers

How to adjust the amount of space between two lines at each <br> in CSS?

I have a document like this: This is ...READ MORE

Aug 23, 2022 in CSS by Edureka
• 13,620 points
799 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,572 views
0 votes
1 answer

Using/Handling colon inside a JSF generated HTML element ID in CSS selector

Yes, you can.  Just Backslash (\) the colon.  Like ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,250 points
2,865 views
0 votes
1 answer

What is a css selector and where is it used?

CSS Selector is a combination of element ...READ MORE

answered Nov 21, 2018 in Data Analytics by Kalgi
• 52,350 points
950 views
0 votes
1 answer

What is the difference between span and div?

The div should be used to wrap sections of ...READ MORE

answered Jan 16, 2020 in Web Development by Niraj

edited Jan 21, 2020 by Niroj 3,678 views
0 votes
1 answer

Should I use px or rem value units in my CSS?

The answer is yes because using px ...READ MORE

answered Jun 21, 2022 in CSS by Edureka
• 12,690 points
568 views
0 votes
1 answer

when declaring css styles, what is the meaning of .classA.classB (two class names with a dot in the middle and no space)

The first example (space-separated classes) is a ...READ MORE

answered Jun 28, 2022 in CSS by Edureka
• 12,690 points
759 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP