Q1. What are margin and padding and when do we use them?
Ans:-Padding and margin are two CSS (Cascading Style Sheets) properties used to control the space around an HTML element.
Padding is the space between an element's content and its border. It is used to create space between the element's content and the edge of the element's box.
Margin is the space outside of an element's border. It is used to create space between the element and other elements or the edge of its containing element. Both padding and margin can be used to adjust the spacing between elements and affect the overall layout of a web page.
Q2. What is display property and explain display inline, block and inline-block?
Ans:- The display property in CSS specifies the type of box an HTML element should generate. It affects the layout and behaviour of an element, including its dimensions, positioning, and rendering.
The following are the most commonly used values of the display property:
i) display: inline: The element is placed inline with the text and only takes up as much width as necessary. The width and height of the element are not respected and any padding or margins will only apply to the left and right of the element.
ii)display: block: The element generates a block-level box, which means it starts on a new line and takes up the full width available. The width and height of the element can be specified, and any padding and margins will be respected.
iii)display: inline-block: The element generates an inline-level box, which means it is placed inline with the text, but it can have a specified width and height. The padding and margins will be respected.
Q3. Explain min-height, min-width, max-height, and max-width in CSS.
Ans:- min-height, min-width, max-height, and max-width are CSS properties that define the minimum and maximum dimensions of an HTML element. They are used to constrain the size of an element, and to ensure that it meets certain size requirements.
i) min-height: The minimum height of an element. The element will not be smaller than the specified value, even if the content within the element requires less space. min-width: The minimum width of an element. The element will not be narrower than the specified value, even if the content within the element requires less space.
ii) max height: The maximum height of an element. The element will not be taller than the specified value, even if the content within the element requires more space.
iii) max-width: The maximum width of an element. The element will not be wider than the specified value, even if the content within the element requires more space.