-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcss-gradient.html
More file actions
691 lines (631 loc) · 43.4 KB
/
Copy pathcss-gradient.html
File metadata and controls
691 lines (631 loc) · 43.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Gradient Generator — Linear, Radial, Conic | FreeDevTool</title>
<meta name="description" content="Free CSS gradient generator. Linear, radial & conic gradients with live preview. Multiple color stops, angle control, OKLCH-aware, copy-ready CSS.">
<meta name="keywords" content="css gradient generator, linear gradient, radial gradient, conic gradient, css background gradient, color stop generator, oklch gradient">
<meta name="robots" content="index, follow">
<meta name="author" content="Anees Ur Rehman">
<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebPage","datePublished":"2026-05-02","dateModified":"2026-05-19","inLanguage":"en-US","isPartOf":{"@type":"WebSite","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<script type="application/ld+json">{"@context":"https://schema.org","@type":"Person","name":"Anees Ur Rehman","url":"https://freedevtool.org/about","jobTitle":"Full-stack developer","worksFor":{"@type":"Organization","name":"FreeDevTool","url":"https://freedevtool.org"}}</script>
<link rel="canonical" href="https://freedevtool.org/css-gradient">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="preload" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap" as="style">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500;600&display=swap">
<link rel="preload" href="style.css?v=20260502-cards" as="style">
<link rel="stylesheet" href="style.css?v=20260502-cards">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/favicon.svg">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="FreeDevTool — 50+ free, fast, privacy-first developer tools">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<meta name="twitter:title" content="CSS Gradient Generator — Linear, Radial, Conic | FreeDevTool">
<meta name="twitter:description" content="Build CSS gradients visually. Live preview, multi-stop, copy-ready code. Runs in browser, no signup.">
<meta property="og:image" content="https://freedevtool.org/og-image.svg">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:image" content="https://freedevtool.org/og-image.svg">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3L0CMH3X36"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag('js',new Date());gtag('config','G-3L0CMH3X36');</script>
<meta property="og:title" content="CSS Gradient Generator Online — Linear & Radial Gradient Maker">
<meta property="og:description" content="Create CSS gradients visually. Linear, radial, conic. Copy code instantly.">
<meta property="og:type" content="website">
<meta property="og:url" content="https://freedevtool.org/css-gradient">
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebApplication","name":"CSS Gradient Generator","url":"https://freedevtool.org/css-gradient","description":"Create beautiful CSS gradients visually with live preview and instant code output.","applicationCategory":"DeveloperApplication","operatingSystem":"Any","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"}}
</script>
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What are the different types of CSS gradients?","acceptedAnswer":{"@type":"Answer","text":"CSS supports three gradient types: linear-gradient (colors transition along a straight line at any angle), radial-gradient (colors radiate outward from a center point as a circle or ellipse), and conic-gradient (colors rotate around a center point like a color wheel). Each has a repeating variant (repeating-linear-gradient, etc.) for creating patterns."}},{"@type":"Question","name":"How do I create a gradient with multiple color stops in CSS?","acceptedAnswer":{"@type":"Answer","text":"Add multiple color stops separated by commas: background: linear-gradient(90deg, #ff0000 0%, #00ff00 50%, #0000ff 100%). Each stop has a color and optional position (percentage or length). Browsers automatically distribute colors evenly if positions are omitted. You can add as many stops as needed for complex gradients."}},{"@type":"Question","name":"Can I use CSS gradients as text backgrounds?","acceptedAnswer":{"@type":"Answer","text":"Yes. Apply the gradient as background, then use background-clip: text and -webkit-background-clip: text with color: transparent. This clips the gradient to the text shape, creating gradient-colored text. This technique works in all modern browsers and is commonly used for hero headings and decorative typography."}},{"@type":"Question","name":"What is the difference between linear and radial gradients?","acceptedAnswer":{"@type":"Answer","text":"Linear gradients transition colors along a straight line at a specified angle. Radial gradients transition outward from a center point in a circle or ellipse. Use linear for backgrounds and overlays; radial for spotlights and circular effects."}},{"@type":"Question","name":"What is a conic gradient used for?","acceptedAnswer":{"@type":"Answer","text":"Conic gradients sweep colors around a center point in a circle. Classic uses: pie charts and progress rings rendered in pure CSS without SVG. Also used for color wheels, spinner animations, and decorative backgrounds. Universal support in modern browsers since 2021."}},{"@type":"Question","name":"Why does my gradient have banding?","acceptedAnswer":{"@type":"Answer","text":"Banding occurs when a gradient transitions between similar colors over a large distance — limited 8-bit color depth shows as visible steps. Three fixes: (1) interpolate in OKLCH for smoother transitions, (2) add subtle noise via background-blend-mode, (3) shorten the gradient range."}}]}
</script>
<style>
.grad-preview{width:100%;height:220px;border-radius:var(--radius);border:1px solid var(--border);margin-bottom:20px;transition:all .3s}
.grad-controls{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.grad-field label{display:block;font-size:11px;color:var(--text3);font-family:var(--mono);margin-bottom:6px;text-transform:uppercase}
.grad-field select,.grad-field input[type="range"]{width:100%;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:8px 10px;color:var(--text);font-family:var(--mono);font-size:12px}
.grad-field input[type="range"]{padding:4px 0;accent-color:var(--accent)}
.angle-val{font-family:var(--mono);font-size:12px;color:var(--accent);float:right}
.stops-list{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.stop-row{display:flex;gap:8px;align-items:center;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:8px 12px}
.stop-row input[type="color"]{width:36px;height:30px;border:none;background:none;cursor:pointer;border-radius:4px}
.stop-row input[type="range"]{flex:1;accent-color:var(--accent)}
.stop-row .stop-pos{font-family:var(--mono);font-size:11px;color:var(--text3);width:36px;text-align:right}
.stop-row button{background:none;border:none;color:var(--text3);cursor:pointer;font-size:16px;padding:0 4px;transition:color .2s}
.stop-row button:hover{color:#ff6b6b}
.grad-code{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:14px;font-family:var(--mono);font-size:12px;color:var(--text);line-height:1.6;word-break:break-all;position:relative}
.grad-code button{position:absolute;top:8px;right:8px}
.presets-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(80px,1fr));gap:8px;margin-bottom:20px}
.preset-swatch{height:50px;border-radius:var(--radius);border:1px solid var(--border);cursor:pointer;transition:transform .2s,border-color .2s}
.preset-swatch:hover{transform:scale(1.05);border-color:var(--accent)}
@media(max-width:600px){.grad-controls{grid-template-columns:1fr}}
</style>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://freedevtool.org/"
},
{
"@type": "ListItem",
"position": 2,
"name": "All Tools",
"item": "https://freedevtool.org/all-tools"
},
{
"@type": "ListItem",
"position": 3,
"name": "CSS Gradient Generator",
"item": "https://freedevtool.org/css-gradient"
}
]
}
</script>
<script src="/ga4-events.js" defer></script>
</head>
<body>
<nav>
<a class="nav-logo" href="/" aria-label="FreeDevTool home"><svg class="logo-mark" width="22" height="22" viewBox="0 0 24 24" aria-hidden="true" fill="none"><rect x="1" y="1" width="22" height="22" rx="6" fill="currentColor" opacity=".12"/><path d="M9.5 8.5L6 12l3.5 3.5M14.5 8.5L18 12l-3.5 3.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>FreeDevTool</a>
<div class="nav-links">
<div class="nav-dropdown" id="tools-dropdown">
<a href="all-tools" onclick="event.preventDefault();this.parentElement.classList.toggle('open')" aria-haspopup="true">Tools <svg class="chev" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg></a>
<div class="nav-dropdown-menu">
<a href="encoding-tools">
<div class="dd-icon">b64</div>
<div class="dd-info"><div class="dd-name">Encoding & Conversion</div><div class="dd-count">11 tools · Base64, YAML, px→rem</div></div>
</a>
<a href="generation-tools">
<div class="dd-icon">{ }</div>
<div class="dd-info"><div class="dd-name">Generation & Formatting</div><div class="dd-count">16 tools · JSON, SQL, gradients</div></div>
</a>
<a href="security-tools">
<div class="dd-icon">#</div>
<div class="dd-info"><div class="dd-name">Security & Hashing</div><div class="dd-count">3 tools · JWT, MD5, SHA</div></div>
</a>
<a href="text-tools">
<div class="dd-icon">.*</div>
<div class="dd-info"><div class="dd-name">Code & Text Tools</div><div class="dd-count">9 tools · Regex, diff, tokens</div></div>
</a>
<a href="devops-tools">
<div class="dd-icon">JS</div>
<div class="dd-info"><div class="dd-name">Optimization & DevOps</div><div class="dd-count">7 tools · Minifiers, cURL, git</div></div>
</a>
<a href="network-tools">
<div class="dd-icon">IP</div>
<div class="dd-info"><div class="dd-name">Network & Time</div><div class="dd-count">4 tools · IP, DNS, timestamps</div></div>
</a>
<a href="seo-tools">
<div class="dd-icon">SEO</div>
<div class="dd-info"><div class="dd-name">SEO & Meta Tools</div><div class="dd-count">3 tools · OG, meta, slug</div></div>
</a>
<div class="nav-dropdown-divider"></div>
<a class="dd-all" href="all-tools">
<div class="dd-icon">All</div>
<div class="dd-info"><div class="dd-name">Browse all 50 tools</div><div class="dd-count">Searchable catalog & categories</div></div>
</a>
</div>
</div>
<a href="/guides">Guides</a>
<a href="about">About</a>
<a href="privacy">Privacy</a>
</div>
</nav>
<div class="wrapper">
<section class="tool-header">
<a class="tool-back" href="/" aria-label="Back to home">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 18l-6-6 6-6"/></svg>
Back
</a>
<span class="tool-badge">CSS</span>
<h1>CSS Gradient Generator — Linear, Radial & Conic</h1>
<p>Create CSS gradients visually with live preview. Build <strong>linear</strong>, <strong>radial</strong>, and <strong>conic</strong> gradients with multiple color stops, custom angles, and instant CSS code output. Supports modern <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_images/Using_CSS_gradients" rel="noopener" style="color:var(--accent)">CSS Images Module Level 4</a> features and OKLCH color interpolation. Drop the generated <code>background:</code> rule directly into your stylesheet.</p>
<div class="last-updated">Last updated: May 2026 · Written by <a href="/about">Anees Ur Rehman</a>, full-stack developer</div>
</section>
<div class="tool-card">
<div class="card-dots"><span></span><span></span><span></span></div>
<div class="tool-body">
<div class="grad-preview" id="grad-preview"></div>
<div class="grad-controls">
<div class="grad-field">
<label>Gradient Type</label>
<select id="grad-type" onchange="updateGradient()">
<option value="linear">Linear</option>
<option value="radial">Radial</option>
<option value="conic">Conic</option>
</select>
</div>
<div class="grad-field" id="angle-field">
<label>Angle <span class="angle-val" id="angle-val">135°</span></label>
<input type="range" id="grad-angle" min="0" max="360" value="135" oninput="updateGradient()">
</div>
</div>
<label style="font-size:11px;color:var(--text3);font-family:var(--mono);text-transform:uppercase;display:block;margin-bottom:8px">Color Stops</label>
<div class="stops-list" id="stops-list"></div>
<button class="btn btn-ghost" onclick="addStop()" style="margin-bottom:16px">+ Add Color Stop</button>
<label style="font-size:11px;color:var(--text3);font-family:var(--mono);text-transform:uppercase;display:block;margin-bottom:8px">Presets</label>
<div class="presets-grid" id="presets-grid"></div>
<div class="grad-code" id="grad-code">
<button class="btn btn-ghost" onclick="copyCSS()" style="padding:4px 12px;font-size:11px">Copy</button>
<span id="css-output"></span>
</div>
</div>
</div>
<div id="toast" style="position:fixed;bottom:30px;left:50%;transform:translateX(-50%);background:var(--accent);color:#000;padding:8px 20px;border-radius:var(--radius);font-size:13px;font-weight:600;opacity:0;transition:opacity .3s;pointer-events:none;z-index:999">Copied!</div>
<!-- =============================================================
LONG-FORM ARTICLE — comprehensive guide for E-E-A-T + ranking.
============================================================= -->
<article>
<p class="aeo-lead" style="font-size:16px;line-height:1.7;color:var(--text);max-width:760px;margin:24px auto 18px;padding:0 4px">
<strong>CSS gradients</strong> come in three types: linear (in a direction), radial (from a point), and conic (around a center, useful for pie charts in pure CSS). Modern browsers also support OKLCH color interpolation, which produces visibly smoother gradient transitions than RGB. This <strong>free CSS gradient generator</strong> handles all three types with multi-stop support and OKLCH output.
</p>
<section id="examples" style="max-width:760px;margin:24px auto 32px">
<h2 style="font-size:18px;margin-bottom:14px">Examples</h2>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Linear gradient with multiple stops§§background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);§§The 135deg angle goes from top-left to bottom-right. Single direction, two stops.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">Conic gradient (pie chart in pure CSS)§§background: conic-gradient(red 0deg 120deg, green 120deg 240deg, blue 240deg 360deg);§§Three sectors making a tricolor pie chart — no SVG required.</strong>
</div>
<div style="background:var(--bg3);border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin-bottom:12px">
<strong style="display:block;color:var(--accent);font-family:var(--mono);font-size:11px;text-transform:uppercase;letter-spacing:1px;margin-bottom:6px">OKLCH gradient (smoother interpolation)§§background: linear-gradient(in oklch, oklch(70% 0.2 30) 0%, oklch(70% 0.2 270) 100%);§§Interpolating in OKLCH instead of RGB avoids the "muddy" mid-tones that appear in RGB gradients between high-saturation colors.</strong>
</div>
</section>
<aside class="founder-note" style="max-width:760px;margin:24px auto 32px;padding:20px 24px;background:rgba(0,208,132,0.05);border-left:3px solid var(--accent);border-radius:6px;font-size:14px;line-height:1.7;color:var(--text2)"><div style="font-family:var(--mono);font-size:11px;color:var(--accent);letter-spacing:1.5px;text-transform:uppercase;margin-bottom:10px;font-weight:600">💡 Why I built this</div><p style="margin:0 0 12px">I built this because most CSS gradient generators online were last updated when only linear gradients existed. Modern CSS has conic gradients (great for pie charts in pure CSS), radial gradients with elliptical sizing, and OKLCH color space — which produces visibly smoother gradient transitions than RGB interpolation. This generator does all of them with live preview.</p><p style="margin:0;font-size:13px;color:var(--text3)">— <a href="/about" style="color:var(--accent);text-decoration:none">Anees Ur Rehman</a>, full-stack developer</p></aside>
<section class="article-section">
<h2>What is a CSS gradient and why use one?</h2>
<p>A <strong>CSS gradient</strong> is a special type of image (yes — image, not color) generated by the browser from a starting color, an ending color, and a transition rule. Defined in <a href="https://www.w3.org/TR/css-images-3/" rel="noopener">CSS Images Module Level 3</a>, gradients let you create smooth color transitions for backgrounds, borders, and overlays without ever loading an image file. They're rendered at any resolution, scale infinitely without pixelation, animate cheaply, and weigh nothing on your bandwidth.</p>
<p>Three flavors cover ~99% of real-world gradient use:</p>
<ul>
<li><strong>Linear gradient</strong> — colors transition along a straight line at any angle. The default for hero backgrounds, button fills, divider strokes, glow effects.</li>
<li><strong>Radial gradient</strong> — colors radiate outward from a center point. Used for spotlight effects, soft circular vignettes, dotted/textured backgrounds with <code>repeating-radial-gradient</code>.</li>
<li><strong>Conic gradient</strong> — colors sweep around a center point like a clock. Used for pie/donut chart visuals, color wheels, loading spinners.</li>
</ul>
<p>All three can be combined, layered, and animated. Modern CSS even supports color-space-aware interpolation (<code>linear-gradient(in oklch, red, blue)</code>) which produces smoother color transitions through brighter perceived midpoints than the default sRGB blending.</p>
</section>
<section class="article-section">
<h2>Linear gradients — the workhorse</h2>
<p>Linear gradients transition colors along a straight line. The angle defines the line direction; color stops define what color appears at what percentage of the way down the line.</p>
<div class="lang-block">
<div class="lang-block-header">linear-gradient</div>
<pre><code>/* Default: top → bottom */
background: linear-gradient(red, blue);
/* Specify angle (clockwise from up) */
background: linear-gradient(45deg, red, blue);
/* Specify side ("to bottom right" — clearest syntax) */
background: linear-gradient(to bottom right, red, blue);
/* Multi-stop with explicit positions */
background: linear-gradient(to right,
red 0%,
yellow 50%,
blue 100%
);
/* Hard stops (no transition between two colors) */
background: linear-gradient(to right, red 50%, blue 50%);
/* Modern: interpolate in OKLCH for smoother midpoint */
background: linear-gradient(in oklch, red, blue);
</code></pre>
</div>
<h3>Common angle reference</h3>
<table class="ref-table">
<thead><tr><th>Angle</th><th>Direction</th><th>"to" syntax</th></tr></thead>
<tbody>
<tr><td><code>0deg</code></td><td>↑ Bottom to top</td><td><code>to top</code></td></tr>
<tr><td><code>45deg</code></td><td>↗ Bottom-left to top-right</td><td><code>to top right</code></td></tr>
<tr><td><code>90deg</code></td><td>→ Left to right</td><td><code>to right</code></td></tr>
<tr><td><code>135deg</code></td><td>↘ Top-left to bottom-right</td><td><code>to bottom right</code></td></tr>
<tr><td><code>180deg</code></td><td>↓ Top to bottom (default)</td><td><code>to bottom</code></td></tr>
<tr><td><code>270deg</code></td><td>← Right to left</td><td><code>to left</code></td></tr>
</tbody>
</table>
</section>
<section class="article-section">
<h2>Radial gradients — for soft, circular effects</h2>
<p>Radial gradients create elliptical or circular color transitions. The shape, size, and center are all customizable.</p>
<div class="lang-block">
<div class="lang-block-header">radial-gradient</div>
<pre><code>/* Default: ellipse centered, fades from inner to outer */
background: radial-gradient(red, blue);
/* Force circle */
background: radial-gradient(circle, red, blue);
/* Position the center */
background: radial-gradient(circle at top right, red, transparent);
/* Custom size */
background: radial-gradient(circle 200px at center, red, blue);
/* Spotlight effect on dark UI */
background: radial-gradient(
circle at 50% 30%,
rgba(0, 208, 132, 0.15) 0%,
transparent 50%
);
/* Repeating radial — for striped backgrounds */
background: repeating-radial-gradient(
circle,
#1a1d20 0px, #1a1d20 2px,
#14171a 2px, #14171a 4px
);
</code></pre>
</div>
<h3>Sizing keywords</h3>
<table class="ref-table">
<thead><tr><th>Keyword</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>closest-side</code></td><td>Gradient ends at nearest box edge</td></tr>
<tr><td><code>closest-corner</code></td><td>Gradient ends at nearest corner</td></tr>
<tr><td><code>farthest-side</code></td><td>Gradient ends at furthest edge (default for ellipse)</td></tr>
<tr><td><code>farthest-corner</code></td><td>Gradient ends at furthest corner (default for circle)</td></tr>
</tbody>
</table>
</section>
<section class="article-section">
<h2>Conic gradients — pie chart magic in pure CSS</h2>
<p>Conic gradients sweep colors around a center point like the hands of a clock. Less common than linear/radial, but uniquely useful for pie/donut charts, color wheels, and progress rings without SVG.</p>
<div class="lang-block">
<div class="lang-block-header">conic-gradient</div>
<pre><code>/* Color wheel — full sweep through hues */
background: conic-gradient(
from 0deg,
red, yellow, lime, cyan, blue, magenta, red
);
/* Pie chart — three slices */
background: conic-gradient(
red 0deg 120deg,
blue 120deg 240deg,
green 240deg 360deg
);
/* Progress ring — 75% complete */
background: conic-gradient(
var(--accent) 0% 75%,
var(--bg3) 75% 100%
);
/* Angled checkerboard */
background:
conic-gradient(#000 90deg, #fff 0 180deg, #000 0 270deg, #fff 0)
0 0/40px 40px;
</code></pre>
</div>
<p>Combined with <code>border-radius: 50%</code>, conic gradients become circular pie charts with zero JavaScript and zero SVG. Combined with <code>mask</code>, they become donut charts. Browser support since 2021 (Chrome 69, Firefox 83, Safari 12.1) — safe for production.</p>
</section>
<section class="article-section">
<h2>Multi-stop & transparent gradients — the advanced patterns</h2>
<h3>Color stops with explicit percentages</h3>
<div class="lang-block">
<div class="lang-block-header">multi-stop</div>
<pre><code>background: linear-gradient(to right,
#ff0080 0%,
#ff8c00 25%,
#ffd700 50%,
#00d084 75%,
#00a8e8 100%
);</code></pre>
</div>
<h3>Transparent gradients for overlays</h3>
<p>Combine a gradient with <code>transparent</code> stops to create vignettes, fades, and image overlays:</p>
<div class="lang-block">
<div class="lang-block-header">overlay</div>
<pre><code>/* Image with bottom-fade-to-black overlay */
.hero {
background:
linear-gradient(to top, rgba(0,0,0,0.8), transparent 60%),
url('hero.jpg') center/cover;
}
/* Glassmorphism / frosted glass */
.glass {
background: linear-gradient(135deg,
rgba(255,255,255,0.1) 0%,
rgba(255,255,255,0.05) 100%
);
backdrop-filter: blur(10px);
}
</code></pre>
</div>
<h3>Multiple gradients layered</h3>
<p>CSS lets you stack gradients (and images) in a single <code>background</code> property, comma-separated. First listed = top layer.</p>
<div class="lang-block">
<div class="lang-block-header">layered</div>
<pre><code>background:
/* Top layer: subtle vignette */
radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.4) 100%),
/* Bottom layer: blue-to-purple fill */
linear-gradient(135deg, #667eea 0%, #764ba2 100%);</code></pre>
</div>
</section>
<section class="article-section">
<h2>Modern color spaces — OKLCH gradients fix the "muddy middle"</h2>
<p>By default, CSS interpolates gradient colors in <strong>sRGB</strong> color space. This produces a perceptually <em>muddy gray</em> at the midpoint between two saturated colors:</p>
<div class="lang-block">
<div class="lang-block-header">muddy-vs-vivid</div>
<pre><code>/* sRGB (default) — midpoint is dull gray-brown */
background: linear-gradient(red, blue);
/* OKLCH — perceptually uniform, midpoint is vibrant purple */
background: linear-gradient(in oklch, red, blue);
/* Other modern color spaces */
background: linear-gradient(in lch, red, blue); /* perceptual */
background: linear-gradient(in hsl shorter hue, red, blue); /* shortest hue path */
background: linear-gradient(in hsl longer hue, red, blue); /* longest hue path */</code></pre>
</div>
<p>Browser support for <code>in <color-space></code> syntax: Chrome 111+, Safari 16.2+, Firefox 113+ (mid-2023). Safe for modern audiences in 2026; provide an sRGB fallback for older browsers.</p>
<div class="article-aside">
<strong>Pro tip:</strong> rainbows (red → yellow → green → blue → purple → red) look <em>amazing</em> in <code>conic-gradient(in oklch longer hue, ...)</code>. The OKLCH path keeps perceived brightness uniform across all hues — your sRGB version always has dull blues and bright yellows.
</div>
</section>
<section class="article-section">
<h2>CSS gradient performance</h2>
<p>Gradients are GPU-accelerated in every modern browser, so a single static gradient costs essentially nothing to render. But three patterns can hurt performance:</p>
<ul>
<li><strong>Animating gradient stops via CSS variables</strong> triggers repaints on every frame. Most browsers can't animate <code>background-image</code> directly. Use <code>opacity</code>/<code>filter</code> on a positioned overlay instead.</li>
<li><strong>Layering 5+ gradients in a single element</strong> increases paint cost. The first 1–2 are free; the 5th adds noticeable cost on low-end mobile.</li>
<li><strong>Repeating gradients with very small repeat units</strong> (e.g. 1px stripes) force the browser to render large textures. Use SVG patterns for fine repeating textures instead.</li>
</ul>
<h3>Animating gradients the right way</h3>
<div class="lang-block">
<div class="lang-block-header">animation</div>
<pre><code>/* WRONG — re-paints the whole gradient every frame */
@keyframes shift {
to { background: linear-gradient(45deg, blue, red); }
}
/* RIGHT — animate background-position on a wider gradient */
.animated {
background: linear-gradient(45deg, red, blue, green, red);
background-size: 400% 400%;
animation: shift 8s ease infinite;
}
@keyframes shift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}</code></pre>
</div>
</section>
<section class="article-section">
<h2>CSS gradient best practices</h2>
<ul>
<li><strong>Use OKLCH interpolation for any gradient with vivid colors.</strong> The default sRGB midpoint is depressing; OKLCH stays vivid.</li>
<li><strong>Always provide a fallback solid color.</strong> <code>background: red; background: linear-gradient(...);</code> — for browsers that don't support the gradient, the solid color shows through.</li>
<li><strong>Use percentages, not pixels, for color-stop positions.</strong> Gradients at <code>0% / 50% / 100%</code> scale with the container; gradients at <code>0px / 100px / 200px</code> only look right at one width.</li>
<li><strong>Test contrast on text overlaid on gradients.</strong> WCAG AA requires 4.5:1 contrast. A gradient that includes light colors needs a darkening overlay or text-shadow for readability.</li>
<li><strong>Don't stack 6+ gradients in one element.</strong> Layer in <code>::before</code> and <code>::after</code> pseudo-elements if you need many. Keeps paint cost manageable.</li>
<li><strong>Avoid animating gradient stops or colors directly.</strong> Animate <code>background-position</code>, <code>opacity</code>, or <code>transform</code> instead.</li>
<li><strong>Use CSS variables for theme switching.</strong> <code>linear-gradient(var(--from), var(--to))</code> lets you change the gradient by updating one variable.</li>
<li><strong>For brand gradients, define them once in design tokens.</strong> Reuse via custom properties — the brand changes once, the whole site updates.</li>
<li><strong>Test on real low-end devices.</strong> 5+ gradient layers with <code>backdrop-filter: blur()</code> can drop a $200 Android to 30fps. Profile before shipping.</li>
<li><strong>Use repeating-* gradients for patterns.</strong> Stripes, checkerboards, dotted backgrounds — all possible with pure CSS, no SVG, no images.</li>
</ul>
</section>
</article>
<section class="faq-section">
<h2>Frequently Asked Questions</h2>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">What are the different types of CSS gradients?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">CSS supports three gradient types: <strong>linear-gradient</strong> transitions colors along a straight line at any angle, <strong>radial-gradient</strong> radiates colors outward from a center point as a circle or ellipse, and <strong>conic-gradient</strong> rotates colors around a center point like a color wheel. Each type also has a repeating variant (<code>repeating-linear-gradient</code>, etc.) useful for creating stripe and pattern effects.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">How do I create a gradient with multiple color stops in CSS?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Add multiple color stops separated by commas: <code>background: linear-gradient(90deg, #ff0000 0%, #00ff00 50%, #0000ff 100%)</code>. Each stop consists of a color and an optional position. Browsers distribute colors evenly if you omit positions. You can add as many stops as needed — use this tool's "+ Add Color Stop" button to experiment visually.</div></div>
<div class="faq-item"><div class="faq-q" onclick="toggleFaq(this)">Can I use CSS gradients as text backgrounds?<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"/></svg></div><div class="faq-a">Yes. Apply the gradient as <code>background</code>, then use <code>background-clip: text</code> and <code>-webkit-background-clip: text</code> with <code>color: transparent</code>. This clips the gradient to the text shape. It works in all modern browsers and is popular for hero section headings, logos, and decorative typography.</div></div>
</section>
<section class="related-section">
<h2>Related Tools</h2>
<div class="related-grid">
<a class="related-card" href="color-picker"><div class="related-icon">🎨</div><div class="related-card-info"><div class="related-card-name">Color Palette</div><div class="related-card-desc">Color harmony and contrast checker</div></div></a>
<a class="related-card" href="css-minifier"><div class="related-icon">CSS</div><div class="related-card-info"><div class="related-card-name">CSS Minifier</div><div class="related-card-desc">Minify and beautify CSS</div></div></a>
<a class="related-card" href="hex-to-rgb"><div class="related-icon">🎨</div><div class="related-card-info"><div class="related-card-name">Hex to RGB</div><div class="related-card-desc">Convert hex to RGB/HSL</div></div></a>
</div>
</section>
<section class="all-tools-section" aria-label="Browse all FreeDevTool developer tools">
<h2>Browse all 50 free developer tools</h2>
<p class="atc-sub">All tools run in your browser, no signup required, nothing sent to a server.</p>
<div class="all-tools-grid">
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">b64</div>
<div class="atc-cat-title"><h3>Encoding & Conversion</h3><span class="atc-cat-count">11 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/base64-encoder">Base64 Encoder / Decoder</a></li>
<li><a href="/base64-image">Image to Base64</a></li>
<li><a href="/byte-converter">Byte Converter (KB / MB / GB)</a></li>
<li><a href="/case-converter">Case Converter</a></li>
<li><a href="/hex-to-rgb">Hex to RGB / HSL</a></li>
<li><a href="/html-entity">HTML Entity Encoder</a></li>
<li><a href="/json-to-csv">JSON to CSV Converter</a></li>
<li><a href="/px-to-rem">PX to REM Converter</a></li>
<li><a href="/string-escape">String Escape / Unescape</a></li>
<li><a href="/url-encoder">URL Encoder / Decoder</a></li>
<li><a href="/yaml-to-json">YAML to JSON Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">{ }</div>
<div class="atc-cat-title"><h3>Formatting & Generators</h3><span class="atc-cat-count">13 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/color-name">Color Name from Hex</a></li>
<li><a href="/color-picker">Color Palette Picker</a></li>
<li><a href="/css-box-shadow">CSS Box Shadow</a></li>
<li><a href="/css-gradient">CSS Gradient Generator</a></li>
<li><a href="/json-formatter">JSON Formatter / Validator</a></li>
<li><a href="/lorem-ipsum">Lorem Ipsum Generator</a></li>
<li><a href="/markdown-preview">Markdown Preview</a></li>
<li><a href="/password-generator">Password Generator</a></li>
<li><a href="/qr-generator">QR Code Generator</a></li>
<li><a href="/sql-formatter">SQL Formatter</a></li>
<li><a href="/uuid-generator">UUID Generator</a></li>
<li><a href="/word-to-markdown">Word to Markdown</a></li>
<li><a href="/xml-formatter">XML Formatter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">JS</div>
<div class="atc-cat-title"><h3>Minifiers & DevOps</h3><span class="atc-cat-count">6 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/chmod-calculator">chmod Calculator</a></li>
<li><a href="/cron-parser">Cron Expression Parser</a></li>
<li><a href="/css-minifier">CSS Minifier</a></li>
<li><a href="/html-minifier">HTML Minifier</a></li>
<li><a href="/js-minifier">JavaScript Minifier</a></li>
<li><a href="/http-status">HTTP Status Codes</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">#</div>
<div class="atc-cat-title"><h3>Security & Hashing</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/hash-generator">Hash Generator (MD5, SHA)</a></li>
<li><a href="/jwt-decoder">JWT Decoder</a></li>
<li><a href="/jwt-generator">JWT Generator</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">.*</div>
<div class="atc-cat-title"><h3>Code & Text</h3><span class="atc-cat-count">8 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/ai-token-counter">AI Token Counter</a></li>
<li><a href="/char-counter">Character & Word Counter</a></li>
<li><a href="/git-cheatsheet">Git Commands Cheatsheet</a></li>
<li><a href="/number-base">Number Base Converter</a></li>
<li><a href="/regex-explainer">Regex Explainer</a></li>
<li><a href="/regex-tester">Regex Tester</a></li>
<li><a href="/text-diff">Text Diff Checker</a></li>
<li><a href="/wcag-contrast">WCAG Contrast Checker</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">IP</div>
<div class="atc-cat-title"><h3>Network & APIs</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/dns-lookup">DNS Lookup</a></li>
<li><a href="/http-request-builder">HTTP Request Builder</a></li>
<li><a href="/ip-lookup">IP Address Lookup</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">⏱</div>
<div class="atc-cat-title"><h3>Time & Dates</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/relative-time">Relative Time Calculator</a></li>
<li><a href="/timestamp-diff">Timestamp Diff</a></li>
<li><a href="/unix-timestamp-converter">Unix Timestamp Converter</a></li>
</ul>
</div>
<div class="atc-cat">
<div class="atc-cat-head">
<div class="atc-cat-icon">SEO</div>
<div class="atc-cat-title"><h3>SEO & Meta</h3><span class="atc-cat-count">3 tools</span></div>
</div>
<ul class="atc-list">
<li><a href="/meta-tag-generator">Meta Tag Generator</a></li>
<li><a href="/og-preview">Open Graph Preview</a></li>
<li><a href="/slug-generator">URL Slug Generator</a></li>
</ul>
</div>
</div>
</section>
</div>
<footer>
<div>© 2026 FreeDevTool — CSS Gradient Generator</div>
<div class="footer-links"><a href="/all-tools">All Tools</a><a href="/about">About</a><a href="/privacy">Privacy Policy</a><a href="/terms">Terms of Use</a></div>
</footer>
<script>
let stops=[{color:'#667eea',pos:0},{color:'#764ba2',pos:100}];
const presets=[
[{color:'#667eea',pos:0},{color:'#764ba2',pos:100}],
[{color:'#f093fb',pos:0},{color:'#f5576c',pos:100}],
[{color:'#4facfe',pos:0},{color:'#00f2fe',pos:100}],
[{color:'#43e97b',pos:0},{color:'#38f9d7',pos:100}],
[{color:'#fa709a',pos:0},{color:'#fee140',pos:100}],
[{color:'#a18cd1',pos:0},{color:'#fbc2eb',pos:100}],
[{color:'#ffecd2',pos:0},{color:'#fcb69f',pos:100}],
[{color:'#ff9a9e',pos:0},{color:'#fecfef',pos:50},{color:'#fecfef',pos:100}],
[{color:'#0c3483',pos:0},{color:'#a2b6df',pos:50},{color:'#6b8cce',pos:100}],
[{color:'#11998e',pos:0},{color:'#38ef7d',pos:100}]
];
function renderPresets(){
const grid=document.getElementById('presets-grid');
grid.innerHTML=presets.map((p,i)=>{
const css=buildGradientCSS(p,'linear',135);
return`<div class="preset-swatch" style="background:${css}" onclick="applyPreset(${i})"></div>`;
}).join('');
}
function applyPreset(i){stops=presets[i].map(s=>({...s}));renderStops();updateGradient();}
function renderStops(){
const list=document.getElementById('stops-list');
list.innerHTML=stops.map((s,i)=>`<div class="stop-row">
<input type="color" value="${s.color}" onchange="stops[${i}].color=this.value;updateGradient()">
<input type="range" min="0" max="100" value="${s.pos}" oninput="stops[${i}].pos=parseInt(this.value);this.nextElementSibling.textContent=this.value+'%';updateGradient()">
<span class="stop-pos">${s.pos}%</span>
${stops.length>2?`<button onclick="removeStop(${i})">×</button>`:''}
</div>`).join('');
}
function addStop(){
const lastColor=stops[stops.length-1].color;
// Generate a slightly different color
const r=Math.floor(Math.random()*256),g=Math.floor(Math.random()*256),b=Math.floor(Math.random()*256);
const hex='#'+[r,g,b].map(x=>x.toString(16).padStart(2,'0')).join('');
stops.push({color:hex,pos:100});
// Redistribute positions
stops.forEach((s,i)=>s.pos=Math.round(i/(stops.length-1)*100));
renderStops();updateGradient();
}
function removeStop(i){if(stops.length<=2)return;stops.splice(i,1);renderStops();updateGradient();}
function buildGradientCSS(stps,type,angle){
const colorStops=stps.map(s=>s.color+' '+s.pos+'%').join(', ');
if(type==='linear')return`linear-gradient(${angle}deg, ${colorStops})`;
if(type==='radial')return`radial-gradient(circle, ${colorStops})`;
if(type==='conic')return`conic-gradient(from ${angle}deg, ${colorStops})`;
return`linear-gradient(${angle}deg, ${colorStops})`;
}
function updateGradient(){
const type=document.getElementById('grad-type').value;
const angle=parseInt(document.getElementById('grad-angle').value);
document.getElementById('angle-val').textContent=angle+'°';
const css=buildGradientCSS(stops,type,angle);
document.getElementById('grad-preview').style.background=css;
document.getElementById('css-output').textContent='background: '+css+';';
// Show/hide angle for radial
document.getElementById('angle-field').style.display=(type==='radial')?'none':'block';
}
function copyCSS(){
const css=document.getElementById('css-output').textContent;
navigator.clipboard.writeText(css);
const t=document.getElementById('toast');t.style.opacity='1';setTimeout(()=>t.style.opacity='0',1500);
}
renderPresets();renderStops();updateGradient();
function toggleFaq(el){el.parentElement.classList.toggle('open');}
</script>
</body>
</html>