xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to set padding at the top of an HTML element using CSS
CSS Online Editor
Run Code
More CSS Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Set padding at top of an HTML element using CSS</title> <!--Internal CSS added--> <style> /* CSS id name used to apply css style to the divs*/ #div-1 { background-color: lightpink; /*background color of the div*/ } #div-2 { padding-top: 10px; /*10px padding at top of the div*/ background-color: lightblue; /*background color of the div*/ } #div-3 { background-color: lightgreen; /*background color of the div*/ } #div-4 { background-color: green; /*background color of the div*/ margin-top: 10px; border: 1px solid green; } #p-1 { padding-top: 10px; /*10px padding at top of the paragraph*/ background-color: white; margin-top:0; } div { min-height: 60px; } </style> </head> <body> <h1>How to set padding at top of an HTML element using CSS?</h1> <h3 style="color:orangered;">Use padding-top css property to set padding at the top of the HTML element</h3> <div id="div-1">First div without padding</div> <div id="div-2">Second div with 10px padding at top</div> <div id="div-3"> <p>Paragraph without padding</p> </div> <div id="div-4"> <p id="p-1">Paragraph with 20px padding at top.</p> </div> </body> </html>