15CSS basics

CSS Padding

Easy15MIN

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:

CSS
1padding-left: 10px;

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

CSS
1padding: 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

TRY ITREPLIT

NOTE

Valitettavasti Replit-palvelu on muuttunut 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

Learn to hack — start here

Hundreds of interactive courses, virtual labs and CTF challenges in your browser. Start a free trial — no card required.