Learn HTML Forms by Building a Registration Form - Step 15

Tell us what’s happening:
Describe your issue in detail here.
I know how does relative units work, but sometimes I still do not understand why they are used in certain cases. For example, we are using margin:0.5rem 0 for the label element, but I have tried to use margin:9px 0 and it works the same even when I resize the screen. So in this case, do we have to use the rem unit or it just a preference? If yes, how does that unit benefit us in this case? Thank you.

  **Your code so far**
/* file: styles.css */
body {
width: 100%;
height: 100vh;
margin: 0;
background-color: #1b1b32;
color: #f5f6f7;
  margin:0.5rem  0

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Learn HTML Forms by Building a Registration Form - Step 15

Link to the challenge:

px is an absolute value so no matter how small the screen gets or how big, it will always be exactly 9 pixels.
rem is a relative value. It is relative to the root element’s font-size. So if the root element’s font size changes, then the size of the element using the rem will change accordingly (based on the font-size of the root-element, not on the size of the browser or window)

more info here about units: CSS Units

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.