Starting With CSS 2 PDF
Starting With CSS 2 PDF
Ans:
Padding represents the amount of inner space an element has, while the margin is
whitespace available surrounding an element.
It’s not possible to set padding to auto padding. However, you can use automa c
se ngs for margins.
It’s not possible to use nega ve values when defining padding, but you can with
margins.
When to use padding:
Change the size of an element. If you want to expand the space around an element,
you can add or increase the padding surrounding it. This can be useful when working
with interac ve items, such as bu ons or image-based links.
Add space between borders and content. Using padding to add space between
content and its corresponding border is one way to ensure the design aligns with
other on-page elements. Doing so can help you increase the whitespace of your
graphic or website, which is fundamental in web design.
When to use margins:
Adjust an element's posi oning. One of the most common reasons to use margins
when designing and developing a site is to change a specific element's posi on.
Using margins can help you move an element based on whether you prefer it to be
centered on your page or posi oned to the right or le . You can also choose if the
element is fixed and will scroll along the page or if it should remain in one place as a
user scrolls.
Overlap elements. If you want to overlap specific elements with one another, you can
do so using margins. Using a nega ve margin value is one of the quickest ways to
allow elements to overlap with one another.
Se ng distance. Se ng the distance between elements is much easier once you're
familiar with margins and how they work. Incorpora ng the right amount of
whitespace can mean the difference between building an a rac ve website thriving
with traffic and turning prospec ve customers away.
2. What is display Property and explain display inline, block, and inline-block?
Ans:
Inline: The element doesn’t start on a new line and only occupy just the width it
requires. You can’t set the width or height.
inline-block: It’s forma ed just like the inline element, where it doesn’t start on a
new line. BUT you can set width and height values.
Block: The element will start on a new line and occupy the full width available. And
you can set width and height values.
3. Explain min-height, min-width, max-height, and max-width in CSS?
Ans:
Property Descrip on