--- id: css-float-examples title: "CSS Float Examples" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["float layout", "float columns", "equal width boxes", "images side by side", "CSS float menu"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "float", "layout"] raw_sources: ["https://www.w3schools.com/css/css_float_examples.asp"] applied_in: [] github_commit: "" --- # [[CSS Float Examples]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) With the `float` property it is easy to float boxes of content side by side β€” combined with `box-sizing: border-box` to keep padding inside the box, `float` builds equal-width columns, image grids, and horizontal menus. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Floating boxes side by side** β€” `float: left` lets you position boxes of content next to each other. [S1] - **`box-sizing: border-box` is essential** β€” it makes the padding stay inside the box so the box does not break when padding is added. [S1] - **Width determines column count** β€” `33.33%` makes three boxes; use `25%` for four, `50%` for two, etc. [S1] - **Equal heights are a known limitation of float** β€” a fixed `height` is one workaround, but Flexbox can automatically stretch boxes to be as long as the longest box. [S1] - **Float also drives horizontal menus** β€” `float` can be used with a list of hyperlinks to create a horizontal menu. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Equal-width column pattern** β€” set `box-sizing: border-box` globally, then float each box left with a percentage width and padding. [S1] - **Image grid pattern** β€” the same float + percentage-width + padding recipe applied to image containers. [S1] - **Fallback for equal heights** β€” fix `height` when floats produce uneven box heights; prefer Flexbox for automatic equalization. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Create Equal Width Boxes** With the `float` property it is easy to float boxes of content side by side. The `box-sizing` property ensures the padding stays inside the box and that it does not break. [S1] ```css * { box-sizing: border-box; } .box { float: left; width: 33.33%; /* three boxes (use 25% for four, and 50% for two, etc) */ padding: 50px; /* if you want space between the images */ } ``` **Images Side By Side** The same floating technique displays images in a grid layout. [S1] ```css .img-container { float: left; width: 33.33%; /* three containers (use 25% for four, and 50% for two, etc) */ padding: 5px; /* if you want space between the images */ } ``` **Create Boxes With Equal Heights** Floated boxes do not automatically share a height. One workaround is to set a fixed height. [S1] ```css .box { height: 500px; } ``` A better alternative is Flexbox, which can automatically stretch boxes to be as long as the longest box. The page references trying a Flexbox version of the layout. [S1] **Navigation Menu** You can also use `float` with a list of hyperlinks to create a horizontal menu. The page does not provide a distinct code block for this example in the fetched source. [S1] β€” Not found in source (exact menu CSS). **All CSS Float Properties (reference table)** [S1] | Property | Description | |----------|-------------| | `box-sizing` | Defines how the width and height of an element are calculated: should they include padding and borders, or not | | `clear` | Specifies what should happen with the element that is next to a floating element | | `float` | Specifies whether an element should float to the left, right, or not at all | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own applied examples are the equal-width box layout, the side-by-side image grid, the equal-height workaround, and a float-based horizontal menu. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Equal-width float columns (language: CSS): ```css * { box-sizing: border-box; } .box { float: left; width: 33.33%; padding: 50px; } ``` Image grid: ```css .img-container { float: left; width: 33.33%; padding: 5px; } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **Float vs Flexbox for equal heights** β€” float boxes do not equalize height on their own (requires a fixed `height`), whereas Flexbox can automatically stretch boxes to match the longest box. The page recommends Flexbox as the better alternative. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) No contradictions found in the source. ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual (μ‹€μ œ 적용 사둀 발견 μ‹œ applied/validated둜 승격 κ°€λŠ₯) - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Float]], [[CSS Inline Block]], [[CSS Horizontal Align]], [[CSS Flexbox]] - **μ°Έμ‘° λ§₯락:** Referenced when building multi-column layouts, image grids, or horizontal menus with the legacy float technique. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Float Examples β€” https://www.w3schools.com/css/css_float_examples.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Float Examples" page (Astra wiki-curation, P-Reinforce v3.1 format).