--- id: css-masking-with-gradients title: "CSS Masking with Gradients" category: "Frontend" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["gradient mask", "linear-gradient mask", "radial-gradient mask", "conic-gradient mask", "mask-image gradient"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.87 created_at: 2026-06-23 updated_at: 2026-06-23 review_reason: "" merge_history: [] tags: ["css", "web", "frontend", "w3schools", "masking", "gradients", "mask-image"] raw_sources: ["https://www.w3schools.com/css/css3_masking_gradients.asp"] applied_in: [] github_commit: "" --- # [[CSS Masking with Gradients]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) A CSS gradient can be used as a mask layer image, letting `mask-image` fade or shape an element using linear, radial, or conic gradients. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Gradient as mask** β€” `mask-image` can take a CSS gradient as its mask layer. [S1] - **Gradient types** β€” the page demonstrates linear, radial (circle and ellipse), and conic gradient masks. [S1] - **Black vs transparent** β€” in a gradient mask, the gradient's opaque (black) regions reveal the element and transparent regions hide it. [S1] - **`-webkit-` prefix** β€” examples pair `mask-image` with `-webkit-mask-image`. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Fade-out mask** β€” `linear-gradient(black, transparent)` fades an element from fully visible to hidden. [S1] - **Soft vignette / spotlight** β€” `radial-gradient(circle, black 50%, rgba(0,0,0,0.5) 50%)` reveals a central region fully and partially dims the rest. [S1] - **Rotational mask** β€” `conic-gradient(black 0deg, transparent 360deg)` sweeps visibility around a center. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) **Linear gradient mask layer** [S1] ```css .mask1 { -webkit-mask-image: linear-gradient(black, transparent); mask-image: linear-gradient(black, transparent); } ``` A second linear-gradient example applies the mask over a background image. [S1] ```css .mask1 { max-width: 600px; height: 400px; background: url(img_5terre.jpg) no-repeat; -webkit-mask-image: linear-gradient(black, transparent); mask-image: linear-gradient(black, transparent); } ``` **Radial gradient mask layer β€” circle** [S1] ```css .mask2 { -webkit-mask-image: radial-gradient(circle, black 50%, rgba(0, 0, 0, 0.5) 50%); mask-image: radial-gradient(circle, black 50%, rgba(0, 0, 0, 0.5) 50%); } ``` **Radial gradient mask layer β€” ellipse** [S1] ```css .mask3 { -webkit-mask-image: radial-gradient(ellipse, black 50%, rgba(0, 0, 0, 0.5) 50%); mask-image: radial-gradient(ellipse, black 50%, rgba(0, 0, 0, 0.5) 50%); } ``` **Conic gradient mask layer** [S1] ```css .mask3 { -webkit-mask-image: conic-gradient(black 0deg, transparent 360deg); mask-image: conic-gradient(black 0deg, transparent 360deg); } ``` **CSS masking properties reference** [S1] | Property | Description | |---|---| | `mask-clip` | Specifies which area is affected by a mask image | | `mask-composite` | Specifies a compositing operation used on the current mask layer with the mask layers below it | | `mask-image` | Specifies an image to be used as a mask layer for an element | | `mask-mode` | Specifies whether the mask layer image is treated as a luminance mask or as an alpha mask | | `mask-origin` | Specifies the origin position of a mask layer image | | `mask-position` | Sets the starting position of a mask layer image | | `mask-repeat` | Specifies how the mask layer image is repeated | | `mask-size` | Specifies the size of a mask layer image | | `mask-type` | Specifies whether an SVG element is treated as a luminance mask or as an alpha mask | ## πŸ› οΈ 적용 사둀 (Applied in summary) The page's own examples are the applied cases: linear, radial (circle/ellipse), and conic gradients applied as mask layers (including one over the `img_5terre.jpg` background). No external project/commit applications found in the source. ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Fade an element out with a linear gradient mask (language: CSS): ```css .mask1 { -webkit-mask-image: linear-gradient(black, transparent); mask-image: linear-gradient(black, transparent); } ``` ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) - **Linear gradient** β€” for directional fades (top-to-bottom, left-to-right). [S1] - **Radial gradient (circle / ellipse)** β€” for a centered spotlight or vignette effect. [S1] - **Conic gradient** β€” for a rotational/angular reveal around a center point. [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.87 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[CSS Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[CSS Masking PNG]], [[CSS Masking SVG]], [[CSS Gradients]] - **μ°Έμ‘° λ§₯락:** Referenced when fading or shaping an element's visibility using a gradient-based mask layer. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” CSS Masking with Gradients β€” https://www.w3schools.com/css/css3_masking_gradients.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-06-23: Initial draft synthesized from the W3Schools "CSS Masking with Gradients" page (Astra wiki-curation, P-Reinforce v3.1 format).