Margin Collapse Example
CSS
Hard
2 views
Problem Description
Show two paragraphs where margins collapse, then fix using padding on a wrapper.
Output Format
Print the HTML+CSS code in one block.
Constraints
Use a wrapper with padding to stop collapse effect.
Official Solution
<!doctype html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<title>meetcode</title>
<style>
.wrap { border: 2px solid #0b5; padding: 12px; }
p { margin: 20px 0; }
</style>
</head>
<body>
<div class='wrap'>
<p>First paragraph on meetcode.</p>
<p>Second paragraph on meetcode.</p>
</div>
</body>
</html>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!