14. Padding

Unlike margin, it adds padding between the element and its content. However, it is not free to use; it is dangerous in a very tight design since it takes up space and increases the width or height of the element. You can remedy it with box-sizing: border-box;, which we will learn in the next lesson.

padding-top

Top padding.

.elemento {
    padding-top: 1rem;
}

padding-right

Right padding.

.elemento {
    padding-right: 2rem;
}

padding-bottom

Bottom padding.

.elemento {
    padding-bottom: 3rem;
}

padding-left

Left padding.

.elemento {
    padding-left: 4rem;
}

padding-inline

Left and right padding.

.elemento {
    padding-inline: 5rem;
}

To apply a different padding to each side, we can use the following syntax:

.elemento {
    padding-inline: 5rem 1rem;
}

The first value being the left padding and the second the right.

padding-block

Top and bottom padding.

.elemento {
    padding-block: 6rem;
}

To apply a different padding to each side, we can use the following syntax:

.elemento {
    padding-block: 6rem 1rem;
}

The first value being the top padding and the second the bottom.

padding

It lets us define several sides in a single line, although it is a bit more complex to memorize.

.elemento {

    /* All sides */
    padding: 5rem;

    /*
    Top and bottom: 6rem
    Right and left: 1rem
    */
    padding: 6rem 1rem;

    /*
    Top: 6rem
    Right and left: 3rem
    Bottom: 1rem
    */
    padding: 6rem 3rem 1rem;

    /*
    Top: 1rem
    Right: 2rem
    Bottom: 3rem
    Left: 4rem
    */
    padding: 1rem 2rem 3rem 4rem;


}

More information

Activity 1

Implement the following image in HTML.

Mailchimp marketing

Activity 2

Implement only one of the columns, whichever you prefer.

If you feel up to it, implement the entire table.

Pricing table

Activity 3

Implement the following image.

Don't use tables. Regarding the + or - you can ignore it. It would also be interesting if you set up a class called open to show or hide (in its absence) the text.

Accordion

This work is under a Attribution-NonCommercial-NoDerivatives 4.0 International license.

Desafíos de programación atemporales y multiparadigmáticos

Desafíos de programación atemporales y multiparadigmáticos

Te encuentras ante un librillo de actividades, divididas en 2 niveles de dificultad. Te enfrentarás a los casos más comunes que te puedes encontrar en pruebas técnicas o aprender conceptos elementales de programación.

Buy the book

Will you buy me a coffee?

This is how I keep writing without ads or paywalls.

Comments

There are no comments yet.