Skip to content

[CSS: Box Model] Margin, Padding, Border, Outline, Width, Height, Box-Sizing, Box-Shadow & Units — Documentation #89

Closed

Description

@ajay-dhangar

This sub-issue covers the CSS Box Model, one of the most essential fundamentals for layout and spacing.
Contributors will document margin, padding, border, outline, sizing, shadows, and CSS units along with examples and diagrams.

This issue corresponds to:

box-model
├── margin.mdx
├── padding.mdx
├── border.mdx
├── outline.mdx
├── width.mdx
├── height.mdx
├── box-sizing.mdx
├── box-shadow.mdx
└── css-units/
    ├── absolute-vs-relative.mdx
    ├── viewport-units.mdx
    ├── units-with-functions.mdx

Each topic should explain:

  • What the property does
  • How it affects layout
  • Syntax examples
  • Common pitfalls
  • UI examples (cards, buttons, sections)

Mermaid Diagram (Include in Issue)

CSS Box Model Overview

graph TD
    A[CSS Box Model] --> B[Content]
    A --> C[Padding]
    A --> D[Border]
    A --> E[Margin]

    C --> C1[padding-top]
    C --> C2[padding-right]
    C --> C3[padding-bottom]
    C --> C4[padding-left]

    D --> D1[border-width]
    D --> D2[border-style]
    D --> D3[border-color]

    E --> E1[margin-top]
    E --> E2[margin-right]
    E --> E3[margin-bottom]
    E --> E4[margin-left]

    A --> F[box-sizing]
    F --> F1[content-box]
    F --> F2[border-box]

    A --> G[box-shadow]
    G --> G1[offset-x]
    G --> G2[offset-y]
    G --> G3[blur]
    G --> G4[spread]
    G --> G5[color]

    A --> H[Units]
    H --> H1[Absolute: px, cm, mm]
    H --> H2[Relative: em, rem]
    H --> H3[Viewport: vw, vh]
    H --> H4[Functions: calc#40;#41;, clamp#40;#41;]
Loading

Tasks

Box Spacing

  • Document margin
  • Document padding
  • Add examples like spacing around cards, diagonal spacing, and collapsing margins

Borders & Outlines

  • Document border
  • Document outline
  • Provide visual comparisons between border vs outline

Sizing

  • Document width
  • Document height
  • Include min/max-width and height references

Box Behavior

  • Document box-sizing
  • Add comparison: content-box vs border-box

Effects

  • Document box-shadow
  • Add soft-shadow UI examples

CSS Units

  • Document absolute units
  • Document relative units (em, rem)
  • Document viewport units (vw, vh, vmin, vmax)
  • Document units with functions (calc, clamp)

General Tasks

  • Add diagrams, spacing visuals, and before/after examples
  • Add best practices (use rem for scalability, use border-box for layout consistency)
  • Add pitfalls (margin collapsing, misusing width with padding)
  • Cross-link with Layout, Flexbox, Grid, and Typography
  • Ensure proper MDX formatting for Docusaurus

Suggested Structure for Each MDX File

  • Overview
  • Syntax
  • Visual example
  • Best practices
  • Common mistakes
  • UI use cases
  • Related links

Expected Outcome

A complete set of MDX documents that help learners clearly understand how elements take up space, how spacing works, and how to properly use the box model in real-world UI layouts.

Activity

  1. added this to the CSS Docs milestone on Nov 15, 2025
  2. github-actions commented on Nov 15, 2025

    @github-actions

    Hi @ajay-dhangar! Thanks for opening this issue. We appreciate your contribution to this open-source project. Your input is valuable and we aim to respond or assign your issue as soon as possible. Thanks again!

  3. github-actions commented on Nov 15, 2025

    @github-actions

    Thanks for adding the documentation label!


    This issue is now marked as needing content updates for the CodeHarborHub site. Please ensure the description contains all necessary technical details.

  4. linked a pull request that will close this issueadded Box Model content #111on Nov 24, 2025
  5. self-assigned this
    on Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions