HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
PHP Tutorial

PHP forms
HTML Tutorial

CSS Tutorial

CSS Margin, top, bottom, left, right

The margin attribute sets "as the name says" a distance beyond the previously set boundary. The defined edge will not have any color, in other words it will be transparent. The CSS margin properties are used to create space around boundary, outside of any defined borders.

Margin - Individual Sides as top, right, bottom, left

With CSS, you have full control over the margins and you can add any value. There are properties for setting the margin for each side of an element (margin-top, margin-right, margin-bottom, and margin-left).

All the margin properties can have the next value:
  • length - specifies a margin in px, pt, cm, etc. for top, bottom, left, right,
  • % - specifies a margin in % of the width of the containing element for top, bottom, left, right,
  • inherit - specifies that the CSS margin should be inherited from the parent element,
Note: Negative value for margin are not allowed for CSS margin-top, margin-right, margin-bottom, margin-left

If the margin property has this four value:
margin: 12px 15px 12px 16px;
top margin is 12px
right margin is 15px
bottom margin is 12px
left margin is 16px

Example:
div-box1 { margin: 12px 15px 12px 16px; }

CSS margin - Shorthand Property

To shorten the code, it is possible to specify all the margin properties in one property.
The css margin property is a shorthand property for the following individual margin properties:
margin-top is 12px
margin-right is 15px
margin-bottom 12px
margin-left 16px

Example:
div-box1 { margin: 12px 15px 12px 16px; }
If the margin property has three values:
margin: 12px 15px 14px;
top margin is 12px
right and left margins are 15px
bottom margin is 14px

Example:
div-box2 { margin: 12px 15px 14px; }
If the margin property has two values:
margin: 15px 20px;
top and bottom margin are 15px
right and left margin are 20px

Example:
div-box3 { margin: 15px 20px; }
If the margin property has one value:
margin: 16px;
all four margins are 16px

Example:
div-box4 { margin: 12px; }

CSS Margin auto alue

You can set the margin property to auto to horizontally center the element within its container.

Example:
div-box5 {
width: 320px;
margin: auto;
border: 1px solid blue;
}

CSS margin top, margin bottom, margin left, margin right, css margin 0 auto CSS Margin, top, bottom, left, righ, auto - css tutorial

3191. How to include, how to incorporate CSS in HTML, css tutorial
How to include, how to incorporate CSS in HTML css tutorial
https://www.agernic.com/css-tutorial/how-to-include-how-to-incorporate-css-in-html.html

822. CSS selectors - CSS tutorials - w3resource

https://www.w3resource.com/css/selectors/CSS-selectors.php

825. Features of w3resource CSS tutorials

https://www.w3resource.com/css/what-you-will-learn.php

813. CSS box model - CSS tutorials - w3resource

https://www.w3resource.com/css/concepts/box-model.php

2804. CSS background, Color, Background Image, css tutorial
CSS background, Color, Background Image css tutorial
http://www.agernic.com/css-tutorial/css-background-color-image-css-tutorial.html

2706. CSS Links - CSS tutorial
EchoEcho.Com : The complete CSS tutorial
http://www.echoecho.com/csslinks.htm

Your add here
PHP html_entity_decode() function

PHP strtolower() function

PHP ltrim() function

PHP ucfirst() function

PHP implode() function

PHP substr() function

PHP str_repeat() function

PHP strstr() function

PHP htmlentities() function

PHP isset() Function

PHP htmlspecialchars_decode() function

PHP strrchr() Function

PHP empty() Function

PHP count() Function

PHP str_split() function

PHP wordwrap() function

Login in PHP - simple login script with PHP MYSQL
HTML Table Width
HTML link tag with example
CSS Text Style Bold - Text Decoration - Text Shadow
SQL WHERE AND & OR multiple conditions
PHP Variables