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.

4 Steps 1 min read Easy

Step-by-Step Guide

  1. 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.
  2. 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;}
  3. Step 3: Set the amount.

  4. 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

G

George Brown

Professional writer focused on creating easy-to-follow pet care tutorials.

35 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: