CSS Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
CSS Topics
css tutorials Introduction
Types Types
Background Properties Background Properties
Text Properties Text Properties
Font Properties Font Properties
Box Properties BOX Properties
Border Properties Border Properties
Margin Properties Margin Properties
Padding Properties Padding Properties
Special Topics Special Topics
Forums Ask Your Doubts
Scraps More about CSS
Feedback Feedback
 




CSS Left Margin


Tutorials Css

Topic

Create blank space on the left side of a table in html using style sheet?
How to set margin on the left side?


Explanation

Property: Left Margin

Usage:
margin-left: 10px;
margin-left: 10pt;
margin-left: 10%;
margin-left: auto;

Definition:
Many times we would need to set margin for our objects. This will set the left margin of the object.
It takes the following values.

a)pt : You can set values in points. (e.g: 10pt or 100pt).
b)px : You can set values in pixels. (e.g: 10px or 100px).
c)% : You can set values in percentage. (e.g: 10% or 100%).
d)auto : This will set a automatic / default margin.

Examples
Example 1:
<div style="margin-left: 20px;">testing left margin</div>

Result:

testing left margin

Note: You can see that the text has moved 20 pixels from left side.

Example 2:
<div style="margin-left: 30pt;">testing left margin</div>

Result:

testing left margin

Note: You can see that the text has moved 30 points from left side.

Example 3:
<div style="margin-left: 10%;">testing left margin</div>

Result:

testing left margin

Note: You can see that the text has moved 10 percentage from left side.

Example 4:
<div style="margin-left: auto;">testing left margin</div>

Result:

testing left margin





A Note
CSS - Cascading Style Sheets can be used along with html tags as explained in this site. This simple CSS will help you to create much elegant and neat html web pages. This does not need any additional softwares or codings. All web browser are capable of handing CSS codes.

Note 2: If required you can using <span> instead of <div> tags. div tag will start and end on new lines. span will not exceed the tag area.
Other Links

web hosting