{"id":226,"date":"2026-04-07T17:10:02","date_gmt":"2026-04-07T17:10:02","guid":{"rendered":"https:\/\/gigz.pk\/css\/?post_type=lesson&#038;p=226"},"modified":"2026-04-07T17:10:03","modified_gmt":"2026-04-07T17:10:03","slug":"spacing-and-alignment","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/","title":{"rendered":"Spacing and Alignment"},"content":{"rendered":"\n<p>Spacing and alignment are essential parts of good web design. They help make your content readable, organized, and visually appealing. Proper spacing improves user experience, while alignment ensures everything looks clean and professional.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Spacing<\/h3>\n\n\n\n<p>Spacing refers to the empty space around elements. It includes the space inside elements and the space between elements.<\/p>\n\n\n\n<p>There are two main types of spacing in CSS<\/p>\n\n\n\n<p>Margin<br>Margin controls the space outside an element. It creates distance between elements.<\/p>\n\n\n\n<p>Example<br>div {<br>margin: 20px;<br>}<\/p>\n\n\n\n<p>Padding<br>Padding controls the space inside an element between the content and its border.<\/p>\n\n\n\n<p>Example<br>div {<br>padding: 15px;<br>}<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why Spacing is Important<\/h3>\n\n\n\n<p>Spacing improves readability by preventing content from looking crowded. It also creates a clean layout and helps guide the user\u2019s attention to important sections.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What is Alignment<\/h3>\n\n\n\n<p>Alignment refers to how elements are positioned on a page. It controls how text, images, and containers are arranged.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Types of Alignment<\/h3>\n\n\n\n<p>Text Alignment<br>Used to align text inside elements.<\/p>\n\n\n\n<p>Example<br>p {<br>text-align: center;<br>}<\/p>\n\n\n\n<p>Common values include left, right, center, and justify.<\/p>\n\n\n\n<p>Horizontal Alignment of Elements<br>You can center block elements using margin.<\/p>\n\n\n\n<p>Example<br>div {<br>width: 50%;<br>margin: auto;<br>}<\/p>\n\n\n\n<p>Flexbox Alignment<br>Flexbox is a modern way to align items easily.<\/p>\n\n\n\n<p>Example<br>.container {<br>display: flex;<br>justify-content: center;<br>align-items: center;<br>}<\/p>\n\n\n\n<p>Justify-content aligns items horizontally.<br>Align-items aligns items vertically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Best Practices for Spacing and Alignment<\/h3>\n\n\n\n<p>Use consistent spacing throughout your website.<br>Avoid too much or too little space.<br>Align elements properly to maintain balance.<br>Use Flexbox or Grid for better layout control.<br>Keep content centered or aligned in a structured way.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>Spacing and alignment play a major role in creating professional websites. By using margin, padding, and alignment techniques correctly, you can build clean and user-friendly designs.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"menu_order":0,"template":"","class_list":["post-226","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spacing and Alignment - CSS learning mastery<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spacing and Alignment - CSS learning mastery\" \/>\n<meta property=\"og:description\" content=\"Spacing and alignment are essential parts of good web design. They help make your content readable, organized, and visually appealing. Proper spacing improves user experience, while alignment ensures everything looks clean and professional. What is Spacing Spacing refers to the empty space around elements. It includes the space inside elements and the space between elements. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/\" \/>\n<meta property=\"og:site_name\" content=\"CSS learning mastery\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-07T17:10:03+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/spacing-and-alignment\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/spacing-and-alignment\\\/\",\"name\":\"Spacing and Alignment - CSS learning mastery\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\"},\"datePublished\":\"2026-04-07T17:10:02+00:00\",\"dateModified\":\"2026-04-07T17:10:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/spacing-and-alignment\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/spacing-and-alignment\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/lesson\\\/spacing-and-alignment\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spacing and Alignment\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/css\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/css\\\/\",\"name\":\"CSS learning mastery\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/css\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spacing and Alignment - CSS learning mastery","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/","og_locale":"en_US","og_type":"article","og_title":"Spacing and Alignment - CSS learning mastery","og_description":"Spacing and alignment are essential parts of good web design. They help make your content readable, organized, and visually appealing. Proper spacing improves user experience, while alignment ensures everything looks clean and professional. What is Spacing Spacing refers to the empty space around elements. It includes the space inside elements and the space between elements. [&hellip;]","og_url":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/","og_site_name":"CSS learning mastery","article_modified_time":"2026-04-07T17:10:03+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/","url":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/","name":"Spacing and Alignment - CSS learning mastery","isPartOf":{"@id":"https:\/\/gigz.pk\/css\/#website"},"datePublished":"2026-04-07T17:10:02+00:00","dateModified":"2026-04-07T17:10:03+00:00","breadcrumb":{"@id":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/css\/lesson\/spacing-and-alignment\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/css\/"},{"@type":"ListItem","position":2,"name":"Spacing and Alignment"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/css\/#website","url":"https:\/\/gigz.pk\/css\/","name":"CSS learning mastery","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/css\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/css\/wp-json\/wp\/v2\/media?parent=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}