CSS Assignment - More with CSS Questions and Answers
Q: What is padding and margin and when do you use them?
A: Padding is the space between the content of an element and its border. It is used to create inner
space within an element, ensuring that the content doesn't touch the edges.
Margin is the space outside the border of an element. It is used to create space between different
elements on a webpage.
Both padding and margin are used to control layout and spacing, with padding affecting the space
inside the element and margin affecting the space outside.
Q: What is the display property and explain display inline, block, and inline-block?
A: The display property determines how an element is displayed on the page. Key values:
- Display: inline: Elements are placed inline with the surrounding text. They take up only as much
width as needed.
- Display: block: Elements take up the full width available, forcing a new line break. They can have
height and width set.
- Display: inline-block: Combines characteristics of inline and block elements. Elements remain
inline but can have explicit width and height.
Q: Explain min-height, min-width, max-height, and max-width in CSS?
A: These properties set limits on the size of elements:
- min-height: Sets the minimum height an element can have, preventing it from being smaller than
the specified value.
- min-width: Sets the minimum width an element can have.
- max-height: Sets the maximum height an element can have.
- max-width: Sets the maximum width an element can have.