Basics of web development

CSS Padding

Easy
15 min

CSS indentation (padding) refers to adding space around an HTML element. Padding is usually used to provide space for the content contained within the element. CSS padding can be used, for example, in the design of buttons, images, and text boxes.

Indentation can be defined using the padding property. You can define the inner space separately for top, bottom, right, and left, or you can define the inner space for all sides at once. For example, if you want to add a 10-pixel padding to the left side, you can write the following rule:

padding-left: 10px;

You can also set an indoor area for all sides at once using the following rule:

padding: 10px;

It is important to consider the use of CSS padding when designing a website, as excessive padding can make the page unclear and difficult to read. On the other hand, too little padding can make the page cramped and unpleasant to view.

In addition to CSS padding, you can also use the margin property, which determines the space outside the element. Margin is usually used to give space around the element, while padding is used to give space inside the element.

Practice

Kokeile itse!

Valitettavasti Replit-palvelu on muuttnut lennosta eikä enää anna suorittaa näitä koodeja suoraan selaimessa. Voit klikata alla olevaa "Open in Replit" linkkiä ja avata koodin Replit-palvelussa. Meillä on työn alla etsiä Replitille korvaaja.

hakatemia pro

Ready to become an ethical hacker?
Start today.

As a member of Hakatemia you get unlimited access to Hakatemia modules, exercises and tools, and you get access to the Hakatemia Discord channel where you can ask for help from both instructors and other Hakatemia members.