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

PHP forms
HTML Tutorial

CSS Tutorial

CSS Padding, top, bottom, left, right

The CSS padding properties are used to generate space around an element's content, inside of any defined borders as top, bottom, left, right. With CSS, you have full control and give any value over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).

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

CSS has properties for specifying the padding for each side of an element top, right, bottom, left:

  • padding-top
  • padding-right
  • padding-bottom
  • padding-left

All the padding properties can have the next values:

  • length - specifies a padding in px, pt, cm, etc. for top, bottom, left, right,
  • % - specifies a padding in % of the width of the containing element for top, bottom, left, right,
  • inherit - specifies that the CSS padding should be inherited from the parent element,

Note: Negative values are not allowed for CSS pading top, right, bottom, left

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

Example:
div-box { padding: 12px 15px 12px 16px; }

CSS Padding - Shorthand Property

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

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

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

Example:
div-box { padding: 15px 20px; }
If the padding property has one value:
padding: 16px;
all four paddings are 16px

Example:
div-box { padding: 16px; }

CSS Padding and Element Width

The CSS width property specifies the width of the element's content area. So, if an element has a specified width, the padding added to that element will be added to the total width of the element.
In the following example, the <div-box> element is given a width of 450px. However, the actual rendered width of the <div-box> element will be 450px (450px + 12px of left padding + 12px of right padding):

Example:
div-box {
width: 450px;
padding: 12px;
}
To keep the width at 450px, no matter the amount of padding, you can use the box-sizing property as.

Example:
div-box {
width: 450px;
padding: 12px;
box-sizing: border-box;
}

CSS Padding, top, bottom, left, right, color, css padding vs margin, css pading inside, css padding order CSS Padding, top, bottom, left, right - css tutorial
CSS Padding, top, bottom, left, right, color, css padding vs margin, css pading inside, css padding order CSS Padding, top, bottom, left, right - css tutorial

3012. CSS Text Style Bold - Text Decoration - Text Shadow, css tutorial
CSS Text Style Bold - Text Decoration - Text Shadow css tutorial
http://www.agernic.com/css-tutorial/css-text-style-bold-text-decoration--text-shadow.html

2593. Basic Syntax of CSS - How to Code CSS, css tutorial
Basic Syntax of CSS - How to Code CSS css tutorial
http://www.agernic.com/css-tutorial/syntax-of-css-how-to-code-css.html

812. CSS (foreground) color - CSS tutorials - w3resource

https://www.w3resource.com/css/color/introduction.php

822. CSS selectors - CSS tutorials - w3resource

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

3301. CSS font color, css tutorial
CSS font color css tutorial
https://www.agernic.com/css-tutorial/css-font-color.html

823. CSS Text Align - CSS tutorials - w3resource

https://www.w3resource.com/css/text/text-align.php

Your add here
PHP count() Function

PHP strcmp() function

PHP explode() function

PHP strtoupper() function

PHP str_repeat() function

PHP empty() Function

PHP define() function

PHP strip_tags() function

PHP strtolower() function

PHP isset() Function

PHP substr() function

PHP wordwrap() function

PHP strlen() function

PHP md5() function

PHP similar_text() function

PHP html_entity_decode() function

CSS align content Property - CSS align text - how to create
PHP Operator Types
SQL mysql order by columns, by date, by asc, by desc, random with PHP
The simplest PHP script
HTML Table Border
HTML Table Rowspan and Colspan