Sharp Tutorial
Margin in CSS

Python

Java

C

C++

HTML/CSS

Java Script

PHP

SQL

C Programs

HTML

  • HTML Home
  • Introduction
  • HTML Element
  • Commonly used tags
  • Hyperlinks
  • Images in HTML
  • Div in HTML
  • Html Forms
  • Html Tables
  • Miscellaneous Topics

CSS

  • Introduction to CSS
  • How to apply CSS
  • CSS Selectors
  • Border in CSS
  • Text Formatting in CSS
  • Font Properties
  • Margin in CSS
  • CSS in List
  • CSS in Link
  • CSS Animation
  • CSS Effects
  • CSS Pagination
  • CSS Media Query

Java Script

  • Java Script Home
  • Introduction to Java Script
  • Variable in Java Script
  • Operators in Java Script
  • If-Else in Java Script
  • Loops in Java Script
  • Array in Java Script
  • Function in Java Script
  • Objects in Java Script
  • Java Script DOM

Margin in CSS

Margin is the property of an element which is used to create space around element

CSS has property for specifying the margin for each side of element.

  • margin-top
  • margin-right
  • margin-bottom
  • margin-left
<!DOCTYPE>
<html>
<style>
.line1{
border-style:solid;
border-color:green;
margin-top:100px;
margin-bottom:100px;
margin-right:150px;
margin-left:80px;
}
</style>
<body>
<p class="line1">Hello World! Welcome to Sharp Tutorial.</p>
<p class="line2">Learn with us CSS in few hours.</p>
</body>
</html>



We can also give all values in single line 

<!DOCTYPE>
<html>
<style>
.line1{
border-style:solid;
border-color:green;
margin:100px 100px 150px 80px;
}
</style>
<body>
<p class="line1">Hello World! Welcome to Sharp Tutorial.</p>
<p class="line2">Learn with us CSS in few hours.</p>
</body>
</html>


  • If margin have one value then all values will be same.
  • If margin have two values then first value will be for margin-top & margin-bottom and second value will be for margin-right & margin-left.
  • If margin have three values then first value will be for top value, second value will be for margin-right & margin-left and third value will be for margin-bottom.

Enquiry about Course

Ask your Question

Click Here

Sharp (2) Tutorials

Video/ C Introduction

Watch video in full size

Video tutorial

Follow by Email
Facebook
Facebook
fb-share-icon
YouTube
Copyright © Sharp Tutorial
Build with WordPress
Wordpress Social Share Plugin powered by Ultimatelysocial
Sharp Tutorial