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 in CSS by Edureka
• 8,060 points
15 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 2 days ago by Edureka
• 9,540 points

Related Questions In CSS

0 votes
1 answer

CSS shadow white line at the end of linear-gradient background

This is a byproduct of the gradient ...READ MORE

answered Jun 1 in CSS by Edureka
• 9,540 points
31 views
0 votes
1 answer
0 votes
1 answer

wildcard * in CSS for classes

Yes you can do this. *[id^='term-']{ ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
9 views
0 votes
1 answer
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
4,482 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,240 points
1,652 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
267 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 2,247 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 in CSS by Edureka
• 9,540 points
8 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 2 days ago in CSS by Edureka
• 9,540 points
9 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP