Understanding CSS Margin
📖 Scenario: You are creating a simple webpage with a heading and a paragraph. You want to add space around these elements so they don't touch the edges of the browser window or each other.
🎯 Goal: Build a webpage with a heading and a paragraph. Use CSS margin properties to add space around these elements so they look neat and separated.
📋 What You'll Learn
Create an HTML structure with a
<h1> heading and a <p> paragraph.Add CSS to give the heading a margin of 2rem on all sides.
Add CSS to give the paragraph a top margin of 1.5rem and bottom margin of 3rem.
Use shorthand margin property for the paragraph.
💡 Why This Matters
🌍 Real World
Adding margin is a common way to create space between elements on a webpage, making content easier to read and visually appealing.
💼 Career
Understanding margin is essential for front-end developers and web designers to control layout and spacing in websites.
Progress0 / 4 steps