Home
CSS
CSS Padding
Tryit: Padding and element width
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> div.ex1 { width: 300px; background-color: yellow; } div.ex2 { width: 300px; padding: 25px; background-color: lightblue; } </style> </head> <body> <h2>Padding and element width</h2> <div class="ex1">This div is 300px wide.</div> <br> <div class="ex2">The width of this div is 350px, even though it is defined as 300px in the CSS.</div> </body> </html>