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 all sides of an HTML element in a single line 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 all sides of an HTML element in a single line 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 { background-color: green; /*background color of the div*/ border: 1px solid red; } #p-1 { padding: 20px 40px 30px 40px; /*top 20px, right 40px, botton 30px, left 40px*/ background-color: white; margin-top: 0; } div { min-height: 60px; } </style> </head> <body> <h1>How to set padding at all sides of an HTML element in a single line using CSS?</h1> <p>Use padding CSS property and set padding at <b style="color:orangered;">top-right-botton-left</b> order.</p> <div id="div-1"> <p>Paragraph without padding</p> </div> <div id="div-2"> <p id="p-1">Using padding CSS property, padding around the paragraph has set at top 20px, right 40px, botton 30px, left 40px.</p> </div> </body> </html>