Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <style> .div1 { box-sizing: content-box; width: 400px; height: 50px; padding: 50px; border: 5px double #1c87c9; } .div2 { box-sizing: border-box; width: 400px; height: 50px; padding: 50px; border: 5px dashed #8ebf42; } </style> </head> <body> <h2>Box-sizing Example</h2> <hr /> <h3>box-sizing: content-box (default):</h3> <div class="div1">The width for this div is set as 400px. Thus, the full width is 400px + 10px (left and right border) + 100px (left and right padding) = 510px.</div> <br> <h3>box-sizing: border-box:</h3> <div class="div2">The width and height apply to all parts of the div element: The full width is 400px.</div> </body> </html>