CSS: Margin & Padding properties

Introduction

When developing a website, we need to provide space around elements & their contents to make the content readable and easy on the eyes. We can do this using two CSS properties: margin & padding.

Margin: It creates space around the element, outside its defined borders.
margin2.webp 34.68 KB


Padding: It creates space around the element's content, inside its defined borders
padding.webp 33.06 KB


Lets look at both of them closely.