Categories
CSS Web development

CSS padding-top Property

CSS padding-top Property

The space between the content and its border is named padding.

The CSS padding-top property settles the top padding (top space) of an element.

Demo:

Click the “Try it” button to change the padding-top property of the paragraph (45px):



This is a paragraph.


Syntax:

padding-top: length;

length – defines fixed top padding in px, cm, etc.

Example:

<!DOCTYPE html>
<html>
<head>
<style>
.ex1 {
  border: 1px solid #333; 
  padding-top: 15px;
}
</style>
</head>
<body>

<p class="ex1">This is a paragraph with a 15px top padding.</p>

</body>
</html>

Output:

This is a paragraph with a 15px top padding.

Enjoy coding!

Read also:

CSS margin-top Property

CSS border-top Property

CSS clear Property