CSS · CSS Tutorial · Lesson 10
CSS Padding
Space inside an element's border.
Padding creates space around an element's content, inside of any defined borders.
Example
<style>
div { border: 2px solid #04AA6D; background: #e8f8f1; margin-bottom: 10px; }
.p1 { padding: 30px; }
.p2 { padding: 10px 50px; }
.p3 { padding-left: 80px; }
</style>
<div class="p1">30px on all sides</div>
<div class="p2">10px top/bottom, 50px left/right</div>
<div class="p3">80px left only</div>
Tip: Padding cannot be negative. With the default box-sizing, padding is added to the element's width.
Keep reading “CSS Padding”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.