How to Use Padding in CSS
Select the element you want to put padding on., Add the amount of padding you want to add using one of the following options: padding-left padding-right padding-top padding-bottom , Set the amount., Check your code for syntax errors.
Step-by-Step Guide
-
Step 1: Select the element you want to put padding on.
For this, you'll want to know the class or ID, ideally.
For example, .wrapper or #header. -
Step 2: Add the amount of padding you want to add using one of the following options: padding-left padding-right padding-top padding-bottom
, As with any distance or size declaration the distance can be given in: px em % vw vh , A correct option for example is this: give our element 20 pixels padding on the right: .wrapper #header {padding-right: 20px;} -
Step 3: Set the amount.
-
Step 4: Check your code for syntax errors.
Detailed Guide
For this, you'll want to know the class or ID, ideally.
For example, .wrapper or #header.
, As with any distance or size declaration the distance can be given in: px em % vw vh , A correct option for example is this: give our element 20 pixels padding on the right: .wrapper #header {padding-right: 20px;}
About the Author
George Brown
Professional writer focused on creating easy-to-follow pet care tutorials.
Rate This Guide
How helpful was this guide? Click to rate: