HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
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

813. CSS box model - CSS tutorials - w3resource

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

2697. EchoEcho.Com - Web Hosting - JavaScript Tutorial - HTML tutorial - CSS Tutorial - Flash Tutorial - Online for free!
Web hosting and tutorials for html javascript css flash. Online web master forum design articles, graphics, tools, tricks and much more
http://www.echoecho.com/

820. CSS media - CSS tutorials - w3resource

https://www.w3resource.com/css/media/introduction-and-types.php

825. Features of w3resource CSS tutorials

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

3189. CSS Text Style - Text Font Size - Text Align, css tutorial
CSS Text Style - Text Font Size - Text Align css tutorial
https://www.agernic.com/css-tutorial/css-text-style-font-size-and-text-align.html

2702. CSS Cursors - CSS tutorial
EchoEcho.Com : The complete CSS tutorial
http://www.echoecho.com/csscursors.htm

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL BETWEEN Operator
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL CREATE DATABASE - example
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL