Task 2. https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_tasks

Task 2:

I just want to know whether am correct or incorrect.

h1 {
font-size: 50px;
}

h2 {
font-size: 2em;
}

p {
font-size:16px;
}

h1+p {
font-size: 120%;
}

Also how does the last tasks

  • A [ <p>element that is directly after an [ <h1> ]
    should be 120%.
    How would this work?

Thank you and I would appreciate the help.

What I didn’t understand was how one element such as em and rem affect one another or the parent element. A small explanation will be really helpful. Also what would the h1+p element do to one another.

Hello @UnknownScript

it will look for h1 element then if it found it will check check what the next element not inside h1 but after h1 if p then it will apply the rule to it
h1 and p are next to each other not parent and child

em and rem are exact the same except on one thing
rem are related to value of the root which is body which it can be calculated faster then em
but em related to parent and if the parent also use em then it will need to calculate the value depend on it’s root till it reach root or a parent that it can get it’s value

if you right click and inspect a page and if they use em you can go to the computed and fonts section in the developer tool and see how the font calculated

one issue of multi nested em that it can get font to very small or very big as it scale

just a little thing when i say that something could make issue that does not mean we do not use it but everything can be used but to keep in mind the in and out of each thing so we can use the right thing for the right case

hope that help and have a nice day :slight_smile:

Sorry I couldn’t reply much quicker. Thank you very much! you have been helping loads.

From the whole information I would just say in-terms of em I understand it plays a part from the parent elements meaning it will check to see whether the parent element has this and then calculate. However rem would depend on its root? would that mean purely the body?

@justsomeone Thankyou!

you very welcome @UnknownScript and do not be sorry

yep root mean body but i did not check what rem will do if it inside iframe would it get it from the main page that include iframe or the iframe in that case will be the root

also i did not test it for subpage

hope that help and have a nice day :slight_smile: