Some questions related to css and js

  1. Explain the three main ways to target elements.
  2. How do you target something inside or around another element?
  3. What is the use of !important?
  4. What is em and rem?
  5. What is mobile-first approach?
  6. Have you used Flexbox & CSS Grid before? What are the differences between them?
  7. What are the variables in css and why it is used for?
    8.Building blocks of programming languages?
    9.Variable naming rules?
1 Like

Hello @ Amaragarwal7 ,
We have received your query.
This was a really nice question which you have asked.

Give us a couple of minutes & we will reach out with the solution for your query.

1 Like

Question 4 Ans:-
em unit and rem unit:- These are the relative units which are relative to something else.

em unit:- The em unit allows setting the font size of an element relative to the font size of its parent. When the size of the parent element changes, the size of the child changes automatically.

When em units are used on font-size property, the size is relative to the font-size of the parent. When used on other properties, it’s relative to the font-size of that element itself. Here, only the first declaration takes the reference of the parent.
Here an example for your better understanding:-

Em vs Rem .parent { font-size: 20px; } .child-em { font-size: 2em; margin: 1.5em; }
This is parent
This is Child in em unit system
The font-size of the .child element will be 40px (2*20px). The margin of .child will be 60px. That’s 1.5 times the font-size of our element (1.5*40px).

rem unit:- The rem is based upon the font-size value of the root element, which is the element. And if the element doesn’t have a specified font-size, the browser default value of 16px is used. So here only the value of the root is considered, and there is no relation with a parent element.

Unlike em, here size is relative for all declarations, not only first.

example:-

Em vs Rem html { font-size: 30px; } .parent { font-size: 20px; } .child-rem { font-size: 2rem; margin: 1.5rem; }
This is parent
This is Child in rem unit system
The font-size of the .child element will be 60px (2*30px). The margin of .child will be 45px. That’s 1.5 times the font-size of the html element (1.5*30px).

mam waiting for answers

1 Like

@Amaragarwal7
Hello,

We have recieved your query.
This was a really nice question which you have asked.

Give us a couple of minutes & we will reach out with the solution for your query

Zeba Kainat| TA- Edyoda