CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



padding-block

Padding-Block is a CSS property that allows you to add padding to the top and bottom of an element. It is a shorthand property for the padding-top and padding-bottom properties. Padding-Block is a relatively new property, introduced in CSS3, and is supported by most modern browsers.

The padding-block property is used to add space between the content of an element and its border. It is particularly useful when you want to add space to the top and bottom of an element, but not to the left and right. This can be especially helpful when working with text, as it can make the text easier to read and more visually appealing.

Here is an example of how to use the padding-block property:

<div style="padding-block: 20px;">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, velit eget ultrices bibendum, velit elit bibendum elit, vel bibendum elit elit vel elit.</p>
</div>

In this example, we have added 20 pixels of padding to the top and bottom of the div element. This will create space between the content of the div and its border.

You can also use the padding-block property to add different amounts of padding to the top and bottom of an element. Here is an example:

<div style="padding-block: 10px 20px;">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, velit eget ultrices bibendum, velit elit bibendum elit, vel bibendum elit elit vel elit.</p>
</div>

In this example, we have added 10 pixels of padding to the top of the div element and 20 pixels of padding to the bottom of the div element.

You can also use the padding-block property in combination with other CSS properties to create more complex layouts. For example, you could use the padding-block property to create a header section with a large amount of padding at the top and a smaller amount of padding at the bottom:

<div style="padding-block: 50px 0 20px 0; background-color: #ccc;">
  <h1>My Header</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, velit eget ultrices bibendum, velit elit bibendum elit, vel bibendum elit elit vel elit.</p>
</div>

In this example, we have added 50 pixels of padding to the top of the div element, 0 pixels of padding to the right and left of the div element, and 20 pixels of padding to the bottom of the div element. We have also added a background color to the div element to make it stand out.

Overall, the padding-block property is a useful tool for creating more visually appealing and readable layouts in your web applications. By adding space between the content of your elements and their borders, you can make your content easier to read and more visually appealing.

References

Activity