English 中文(简体)
CSS - Padding
  • 时间:2024-09-17

CSS - Paddings


Previous Page Next Page  

The padding property allows you to specify how much space should appear between the content of an element and its border −

The value of this attribute should be either a length, a percentage, or the word inherit. If the value is inherit, it will have the same padding as its parent element. If a percentage is used, the percentage is of the containing box.

The following CSS properties can be used to control psts. You can also set different values for the padding on each side of the box using the following properties −

    The padding-bottom specifies the bottom padding of an element.

    The padding-top specifies the top padding of an element.

    The padding-left specifies the left padding of an element.

    The padding-right specifies the right padding of an element.

    The padding serves as shorthand for the preceding properties.

Now, we will see how to use these properties with examples.

The padding-bottom Property

The padding-bottom property sets the bottom padding (space) of an element. This can take a value in terms of length of %.

Here is an example −

<html>
   <head>
   </head>
   
   <body>
      <p style = "padding-bottom: 15px; border:1px sopd black;">
         This is a paragraph with a specified bottom padding
      </p>
      
      <p style = "padding-bottom: 5%; border:1px sopd black;">
         This is another paragraph with a specified bottom padding in percent
      </p>
   </body>
</html> 

It will produce the following result −