Click here to Skip to main content
16,020,633 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi there I want to change the default height=16px for using rem em units can someone explain me how can I change it?

What I have tried:

I tried min-height in body element style but it didn't work
Posted
Updated 25-Feb-24 23:26pm
v2

Try to change the font size of your html element, not the body font size.
https://stackoverflow.com/questions/48451764/how-to-set-base-size-for-rem[^]
 
Share this answer
 
Ah, the wonderful world of em and rem units, and the sizes they use. You're probably aware that the (r)em has a default value of 16 pixels. What you might be less aware of is that these units default to the container that they are set in. For example, suppose I create a representation of a container which I call peter (for vanity's sake). If I set this
CSS
.peter {
  font-size: 10px;
}
p {
  font-size: 2em;
}
When I see a paragraph element in .article, it will take the value 20 pixels because the container has been set to 10 pixels. Now, rem units are slightly different in that, they are set relative to the root container. So, suppose we wanted to change the font size using rem, how would we do this? As we know that rems are set relative to the root container, then we set the default in the root element. What this looks like is
CSS
html {
  font-size: 10px;
}
p {
  font-size: 2rem;
}
Now, unless we override the font size with a local container, our font size is going to be 20 pixels for each paragraph.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900