CodeLab
Tutorials For Everyone
Run
<!Doctype HTML> <html> <head> <title>CSS Padding With Element Width</title> <style> .div1{ padding: 100px; width: 200px; background: #555; color: #fff; } .div2{ padding: 0; width: 200px; background: #3949ab; color: #fff; } </style> </head> <body> <h2>CSS Padding with Element Width</h2> Padding is added to the total width of the element. <div class="div1"> This div element has width of 200px with 100px padding. </div> <div class="div2"> This div element has width of 200px with 0px padding. </div> </body> </html>