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

3183. CSS Introduction Tutorial, css tutorial
CSS Introduction Tutorial css tutorial
https://www.agernic.com/css-tutorial/css-introduction-tutorial.html

2232. CSS Tutorial - Font and font families
There are mainly two types of fonts which are: serif and sans serif. There isn
https://tutorialehtml.com/en/css-tutorial-font-and-font-families/

3185. CSS Margin, top, bottom, left, righ, auto, css tutorial
CSS Margin, top, bottom, left, righ, auto css tutorial
https://www.agernic.com/css-tutorial/css-margin-top-bottom-left-righ-auto.html

2109. CSS Tutorial - Introduction to CSS
With the help of CSS we can create simple or complex websites, you can build that fancy design that you always like it.
https://tutorialehtml.com/en/css-tutorial-introduction-to-css/

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

3178. CSS code, Tags, Example, CSS, Editor, Online Courses, Training
Online CSS Tutorial pdf, what is CSS, Online Courses, Classes, Training, Tutorials for Beginners - agernic.com is a free interactive Code, Tags, Example, CSS, Editor, Online Courses, Training for beginners
https://www.agernic.com/css-tutorial.html

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