How to set the top padding of a text using pixel (px) values with CSS
The below HTML and CSS code example shows you how to set the top padding of a text using pixel (px) values with CSS.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>this is the title of the web page</title>
<style type="text/css">
</style>
</head>
<body>
<p style="margin: 0px; border: solid 1px; padding-top: 30px;">
This paragraph has a top padding of 30px.
</p>
<p style="margin: 0px; border: solid 1px; padding-top: 0px;">
This paragraph has a top padding of 0px.
</p>
</body>
</html>
The above HTML and CSS code makes the paragraphs below. The paragraphs have each been given a border to make it easier to tell where the padding is.
This paragraph has a top padding of 30px.
This paragraph has a top padding of 0px.
Use the text editor below to practice setting the top padding of a text using pixel values.