Learn HTML
CSS Introduction
CSS Basic Syntax
CSS Selector
CSS Units
CSS Text
CSS Border
CSS Outline
CSS Padding
CSS Margin
CSS Height & Width
CSS Overflow
CSS Resize
CSS Background
CSS Box Sizing
CSS Position
CSS Float
CSS Clear
CSS Clip Path & Shape Outside
CSS Display
CSS Media Queries
CSS Pseudo Classes & Elements
CSS Filter
CSS Transition
CSS Transform
CSS Animation
CSS List Style
CSS Table
CSS Scrollbar Styling
CSS Icon
CSS Cursor
CSS Variable & Calc
CSS User Select
CSS Flexbox
Learn Javascript
Learn Django
We know that the space between content and border is called padding. It means
padding gives space from inside but margin give space from outside. Suppose we have
two div and we want space between two div. In that case we use
margin. It will give space between to div. Now if we want to give space between div and div content(present
inside div) then we will use padding.
margin-top:
This property is used to give margin at top.
Pass value in pixel, percentage, etc.
margin-bottom:
This property is used to give margin at bottom.
Pass value in pixel, percentage, etc.
margin-left:
This property is used to give margin at left.
Pass value in pixel, percentage, etc.
margin-right:
This property is used to give margin at right.
Pass value in pixel, percentage, etc.
margin:auto;
By using this property, the elements will take margin automatically.
margin:
This is a shorthand technique.
Example 1:
margin:margin_top margin_right margin_bottom margin_left ;
margin: 25px 50px 75px 100px;
Example 2:
margin:margin_top margin_right_and_left margin_bottom ;
margin: 25px 50px 75px ;
Example 3:
margin:margin_top_and_bottom margin_right_and_left ;
margin: 25px 50px;
Example 4:
margin:all_side;
margin: 25px ;