Search This Blog

Q1-Q5

Q1. What is Box model?
Q2. What is specificity in CSS?
Q3. What is the difference between Static, Relative, Absolute and Fixed position in CSS?
Q4. Difference between visibility:hidden and display:none?
Q5. What is DOM?

--------------------------------------------------------------------------------------------------------------------------
Q1. What is Box Model?


Answer:

The CSS box model is essentially a box that wraps around every HTML element. It consists of: margins, borders, padding, and the actual content



  • Content - The content of the box, where text and images appear
  • Padding - Clears an area around the content. The padding is transparent
  • Border - A border that goes around the padding and content
  • Margin - Clears an area outside the border. The margin is transparent
--------------------------------------------------------------------------------------------------------------------------
Q2. What is specificity in CSS?

Answer:
  • Specificity is the means by which browsers decide which CSS property values are the most relevant to an element and, therefore, will be applied. Specificity is based on the matching rules 
  • If there are two or more conflicting CSS rules that point to the same element, the browser follows some rules to determine which one is most specific and therefore wins out
https://www.w3schools.com/css/css_specificity.asp
--------------------------------------------------------------------------------------------------------------------------
Q3. What is the difference between Static, Relative, Absolute and Fixed position in CSS?

Answer:
There are 5 different positions values
  1. static
  2. relative
  3. fixed
  4. absolute 
  5. sticky
Above 5 positions are affected by 4 different properties. Above positions will not work unless we define the below properties.
  1. Top
  2. Bottom
  3. Left
  4. Right

position:static
  • HTML elements are positioned static by default.
  • Static positioned elements are not affected by the top, bottom, left, and right properties.
  • An element with position: static; is not positioned in any special way; it is always positioned according to the normal flow of the page:


position:relative

  • An element with position: relative; is positioned relative to its normal position.
  • Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. 
  • Other content will not be adjusted to fit into any gap left by the element.



position:fixed
  • An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element.
  • A fixed element does not leave a gap in the page where it would normally have been located.


position:absolute
  • It is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).
  • However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.


position:sticky
  • An element with position: sticky; is positioned based on the user's scroll position.
  • A sticky element toggles between relative and fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).

--------------------------------------------------------------------------------------------------------------------------
Q4. Difference between visibility:hidden and display:none?

Answer:
When display is none. element is not present and it does not hold the space on html. 
--------------------------------------------------------------------------------------------------------------------------
Q5. What is DOM?

Answer:
  • DOM- Document Object model. It is object oriented representation of webpage which can be modified using scripting languages like javascript. 
  • DOM Model represent a document with a logic tree. 
  • Every html tag is call object as per DOM Model. 
--------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment