--- id: css-rwd-media-queries title: "CSS RWD Media Queries" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["media queries", "@media rule", "breakpoints", "RWD media queries", "responsive breakpoints"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "responsive", "media-queries"] raw_sources: ["https://www.w3schools.com/css/css_rwd_mediaqueries.asp"] applied_in: [] github_commit: "" --- # [[CSS RWD Media Queries]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) CSS media queries use the `@media` rule to apply different styles based on a device's characteristics (such as viewport width or orientation), letting one stylesheet rearrange layout, hide elements, and adapt across breakpoints. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Media query** β€” media queries allow you to apply styles based on the characteristics of a device or the environment displaying the web page, and are essential for creating responsive web pages. [S1] - **`@media` rule** β€” the rule used to implement media queries in a stylesheet. [S1] - **Breakpoint** β€” a viewport width at which the layout changes; styles inside a `@media (min-width: ...)` or `(max-width: ...)` block take effect once that condition is met. [S1] - **Orientation** β€” queries can target `orientation: landscape` (or portrait). [S1] - **Conditional visibility** β€” media queries can hide elements (`display: none`) at certain widths. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Min-width breakpoints** β€” start with a base/mobile layout, then add `@media (min-width: X)` blocks that progressively rearrange the grid for larger screens. [S1] - **Standard device breakpoints** β€” reuse a known set of breakpoints (600 / 768 / 992 / 1200 px) rather than ad-hoc values. [S1] - **Orientation-aware styling** β€” switch styles between landscape and portrait with an orientation query. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **What is a Media Query?** CSS media queries allow you to apply styles based on the characteristics of a device or the environment displaying the web page. They are essential for creating responsive web pages. Media queries are implemented with the `@media` rule. [S1] **Add a Breakpoint** β€” A breakpoint at 600px rearranges the grid areas once the viewport is at least that wide: [S1] ```css @media (min-width: 600px) { .header {grid-area: 1 / span 6;} .menu {grid-area: 2 / span 1;} .content {grid-area: 2 / span 4;} .facts {grid-area: 2 / span 1;} .footer {grid-area: 3 / span 6;} } ``` **Another Breakpoint** β€” Stacking two breakpoints (600px and 768px) produces a distinct tablet view and desktop view: [S1] ```css @media (min-width: 600px) { .header {grid-area: 1 / span 6;} .menu {grid-area: 2 / span 1;} .content {grid-area: 2 / span 4;} .facts {grid-area: 3 / span 6;} .footer {grid-area: 4 / span 6;} } @media (min-width: 768px) { .header {grid-area: 1 / span 6;} .menu {grid-area: 2 / span 1;} .content {grid-area: 2 / span 4;} .facts {grid-area: 2 / span 1;} .footer {grid-area: 3 / span 6;} } ``` **Typical Device Breakpoints** β€” There are tons of screens and devices with different heights and widths, so it is hard to create an exact breakpoint for each device. To keep things simple you could target five groups: [S1] ```css /* Extra small devices (phones, 600px and down) */ @media only screen and (max-width: 600px) {...} /* Small devices (portrait tablets and large phones, 600px and up) */ @media only screen and (min-width: 600px) {...} /* Medium devices (landscape tablets, 768px and up) */ @media only screen and (min-width: 768px) {...} /* Large devices (laptops/desktops, 992px and up) */ @media only screen and (min-width: 992px) {...} /* Extra large devices (large laptops and desktops, 1200px and up) */ @media only screen and (min-width: 1200px) {...} ``` **Orientation: Portrait / Landscape** β€” Media queries can also be used to change the layout of a page depending on the orientation of the browser. You can have a set of CSS properties that will only apply when the browser window is wider than its height, a so called "Landscape" orientation: [S1] ```css @media only screen and (orientation: landscape) { body { background-color: lightblue; } } ``` **Hide Elements With Media Queries** β€” Another common use of media queries is to hide elements on different screen sizes: [S1] ```css /* Hide element if the viewport width is 600px or less */ @media screen and (max-width: 600px) { #div1 { display: none; } } ``` Note: the page also mentions practical applications such as resizing fonts and respecting `prefers-reduced-motion` user preferences; the exact inline code for those was not captured beyond the examples above β€” Not found in source. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) The breakpoint examples above rearrange the grid layout from the [[CSS RWD Grid View]] lesson (header/menu/content/facts/footer) as the viewport grows, and demonstrate hiding `#div1` and switching the body background on landscape. No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Single min-width breakpoint (language: CSS): ```css @media (min-width: 600px) { /* styles that apply at 600px and wider */ } ``` Hide an element below a width (language: CSS): ```css @media screen and (max-width: 600px) { #div1 { display: none; } } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **`min-width` vs `max-width`** β€” `min-width` styles apply at the given width and wider (mobile-first, additive); `max-width` styles apply at the given width and narrower (desktop-first). The typical-breakpoints listing pairs `max-width: 600px` for the extra-small group with `min-width` queries for all larger groups. [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.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS RWD Grid View]], [[CSS RWD Viewport]], [[CSS RWD Images]] - **μ°Έμ‘° λ§₯락:** The mechanism that adapts a grid layout across the standard device breakpoints in responsive design. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS RWD Media Queries β€” https://www.w3schools.com/css/css_rwd_mediaqueries.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS RWD Media Queries" page (Astra wiki-curation, P-Reinforce v3.1 format).