--- id: css-media-queries title: "CSS Media Queries" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["@media rule", "media query", "responsive breakpoints", "min-width max-width CSS", "media types features"] 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", "media-queries", "responsive", "at-rules"] raw_sources: ["https://www.w3schools.com/css/css3_mediaqueries.asp"] applied_in: [] github_commit: "" --- # [[CSS Media Queries]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) CSS media queries apply styles conditionally based on a device's or environment's characteristics (such as viewport width), via the `@media` rule, making them essential for responsive web pages. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **What they do** β€” media queries allow you to apply styles based on the characteristics of the device or environment displaying the web page. [S1] - **Why they matter** β€” they are essential for creating responsive web pages. [S1] - **Mechanism** β€” the `@media` rule is used to implement media queries. [S1] - **Media type is optional** β€” the media-type is optional unless you use `not`. [S1] - **Combining conditions** β€” a query is true when the type matches and all listed features are true; `and` combines the type with features; `not` inverts the query. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Conditional style block** β€” wrap rules in `@media … { … }` so they apply only when the conditions match. [S1] - **Mobile-then-up pattern** β€” use `min-width` to add styles as the viewport gets wider. [S1] - **Range pattern** β€” combine `min-width` and `max-width` with `and` to target a width range. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) CSS 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. The `@media` rule is used to implement them. [S1] **Media query syntax** [S1] ```css @media [not] media-type and (media-feature: value) and (media-feature: value) { /* CSS rules to apply */ } ``` Key points: the media-type is optional unless using `not`; the query is true when the type matches and all features are true; `not` inverts the query; `and` combines the type with features. [S1] **CSS media types** [S1] | Value | Description | |-------|-------------| | `all` | All media type devices | | `print` | Print preview mode | | `screen` | Computer screens, tablets, smart-phones | **CSS media features** [S1] | Value | Description | |-------|-------------| | `max-height` | Maximum viewport height | | `min-height` | Minimum viewport height | | `height` | Viewport height (including scrollbar) | | `max-width` | Maximum viewport width | | `min-width` | Minimum viewport width | | `width` | Viewport width (including scrollbar) | | `orientation` | Landscape or portrait | | `resolution` | Screen resolution | | `prefers-color-scheme` | User's preferred color scheme (light/dark) | **Example 1 β€” change background if viewport is 480px or wider** [S1] ```css @media screen and (min-width: 480px) { body { background-color: lightgreen; } } ``` **Example 2 β€” change background if viewport is between 480px and 768px** [S1] ```css @media screen and (min-width: 480px) and (max-width: 768px) { body { background-color: lightgreen; } } ``` ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's applied examples set the `body` background to `lightgreen` once the viewport reaches `480px` (Example 1) and restrict that styling to the `480px–768px` range using `and` with both `min-width` and `max-width` (Example 2). No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Width-up rule (language: CSS): ```css @media screen and (min-width: 480px) { body { background-color: lightgreen; } } ``` Width-range rule (language: CSS): ```css @media screen and (min-width: 480px) and (max-width: 768px) { body { background-color: lightgreen; } } ``` ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (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 Media Queries Examples]], [[CSS Variables in Media Queries]], [[CSS Flexbox]], [[CSS Box Sizing]] - **μ°Έμ‘° λ§₯락:** Referenced whenever styles must adapt to viewport size, orientation, print, or user color-scheme preference. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Media Queries β€” https://www.w3schools.com/css/css3_mediaqueries.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Media Queries" page (Astra wiki-curation, P-Reinforce v3.1 format).