0% found this document useful (0 votes)
12 views

Starting With CSS 2 PDF

Padding adds inner space within an element, while margin adds outer space around an element. Padding is used to expand the space around an element or add space between borders and content. Margins are used to position elements, allow overlapping, and set distance between elements. Display property determines if an element is inline, block, or inline-block. Inline elements don't start on a new line and only occupy the space they require, while block elements start on a new line and occupy the full width. Inline-block elements are formatted like inline but can set width and height. Min/max properties set minimum and maximum bounds for height, width, etc.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Starting With CSS 2 PDF

Padding adds inner space within an element, while margin adds outer space around an element. Padding is used to expand the space around an element or add space between borders and content. Margins are used to position elements, allow overlapping, and set distance between elements. Display property determines if an element is inline, block, or inline-block. Inline elements don't start on a new line and only occupy the space they require, while block elements start on a new line and occupy the full width. Inline-block elements are formatted like inline but can set width and height. Min/max properties set minimum and maximum bounds for height, width, etc.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1. What is padding and margin and when do you use them?

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

height Sets the height of an element

max-height Sets the maximum height of an element

max-width Sets the maximum width of an element

min-height Sets the minimum height of an element

min-width Sets the minimum width of an element

width Sets the width of an element

You might also like