<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Clicktoolset</title>
    <description>The latest articles on DEV Community by Clicktoolset (@clicktoolset).</description>
    <link>https://dev.to/clicktoolset</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4191144%2Fc5ad1761-9c9e-45e5-aaa8-7c0422414166.png</url>
      <title>DEV Community: Clicktoolset</title>
      <link>https://dev.to/clicktoolset</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/clicktoolset"/>
    <language>en</language>
    <item>
      <title>I Built an Image Resizer That Hits Exact Pixel Sizes (Not 'Close Enough')</title>
      <dc:creator>Clicktoolset</dc:creator>
      <pubDate>Wed, 02 Dec 2026 09:12:39 +0000</pubDate>
      <link>https://dev.to/clicktoolset/i-built-an-image-resizer-that-hits-exact-pixel-sizes-not-close-enough-4m93</link>
      <guid>https://dev.to/clicktoolset/i-built-an-image-resizer-that-hits-exact-pixel-sizes-not-close-enough-4m93</guid>
      <description>&lt;p&gt;Every platform states its image size in pixels, and every platform states a different one. An Instagram post wants 1080 x 1080. A YouTube thumbnail wants 1280 x 720. An X header wants 1500 x 500. Upload the wrong numbers and the platform does not complain - it just crops your photo itself, usually through somebody's forehead.&lt;/p&gt;

&lt;p&gt;So I built a resizer that runs 100% in the browser: drop in a photo, tap a preset or type the exact size, and the downloaded file is exactly those pixels. It accepts JPG, PNG, WebP and GIF up to 25 MB. No server, no uploads, nothing leaves the page.&lt;/p&gt;

&lt;p&gt;Here is what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four modes, one idea: never make the user do ratio math
&lt;/h2&gt;

&lt;p&gt;The tool offers Exact size, Width only, Height only, and Percentage. Three of the four exist for one reason: aspect-ratio arithmetic is where people give up. With the aspect lock on, typing a width fills in the matching height automatically:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Width only, aspect lock on: the height is not a guess, it is the same ratio&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;dimsForWidth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;origW&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;origH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targetW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;targetW&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;targetW&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;origH&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;origW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A phone photo at 4032 x 3024 with the width set to 1200 comes out at 1200 x 900 - 1,080,000 pixels instead of 12,192,768, which is 91.1% fewer pixels with the same proportions and the same photo. Percentage mode is the same trick in one step: 50% of 4032 x 3024 is 2016 x 1512, and because both sides halve, the pixel count drops to exactly a quarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  The interesting decision is what happens when the shapes disagree
&lt;/h2&gt;

&lt;p&gt;Your photo is 4:3. An Instagram story is 9:16. Those shapes cannot both win, and every resizer quietly picks a winner for you. I made it an explicit choice instead, and the whole thing is one line of difference in the draw call:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fit&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'cover'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Fill and crop: scale until the frame is covered, trim the overflow&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tw&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;origW&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;th&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;origH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Fit within: scale until the whole photo fits, letterbox the rest&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;sc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tw&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;origW&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;th&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;origH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Math.max&lt;/code&gt; versus &lt;code&gt;Math.min&lt;/code&gt;. That is the entire difference between the two honest options. The third option, Stretch, skips the scale factor and draws straight to the target - included because sometimes the shape change is tiny, and labelled plainly because faces get wider.&lt;/p&gt;

&lt;p&gt;Here is what those lines do to a real photo. Take the 4032 x 3024 shot and target a story at 1080 x 1920:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fit&lt;/th&gt;
&lt;th&gt;What actually happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fill and crop&lt;/td&gt;
&lt;td&gt;Scales to 2560 x 1920, then trims the sides - 57.8% of the width is cut away&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fit within&lt;/td&gt;
&lt;td&gt;Scales to 1080 x 810 and centres it on the 1080 x 1920 canvas - 1,110 px of empty space, nothing cropped&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stretch&lt;/td&gt;
&lt;td&gt;Draws 4:3 into 9:16 - everyone in the photo gets noticeably taller&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Neither honest option is "correct". A document scan must never lose an edge (Fit within); a story post will be cropped by the platform anyway, so you may as well choose the crop yourself (Fill and crop). The tool's job is to show the trade-off, not hide it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The presets are just the modes with the numbers filled in
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Preset&lt;/th&gt;
&lt;th&gt;Pixels&lt;/th&gt;
&lt;th&gt;Shape&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Instagram post&lt;/td&gt;
&lt;td&gt;1080 x 1080&lt;/td&gt;
&lt;td&gt;Square&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Instagram story&lt;/td&gt;
&lt;td&gt;1080 x 1920&lt;/td&gt;
&lt;td&gt;Tall, 9 by 16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;YouTube thumbnail&lt;/td&gt;
&lt;td&gt;1280 x 720&lt;/td&gt;
&lt;td&gt;Wide, 16 by 9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;X header&lt;/td&gt;
&lt;td&gt;1500 x 500&lt;/td&gt;
&lt;td&gt;Very wide, 3 by 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pinterest pin&lt;/td&gt;
&lt;td&gt;1000 x 1500&lt;/td&gt;
&lt;td&gt;Tall, 2 by 3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LinkedIn post&lt;/td&gt;
&lt;td&gt;1200 x 627&lt;/td&gt;
&lt;td&gt;Wide, about 1.91 by 1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A preset sets the numbers, not the composition - a square crop of a wide landscape still cuts off the sides, which is exactly what the fit choice above is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  The file-size cap is borrowed - with one deliberate difference
&lt;/h2&gt;

&lt;p&gt;The resizer also takes an optional max file size in KB, and for that I reused the engine from my exact-size compressor: a binary search over JPEG quality between 0.05 and 0.92, seven rounds, keeping the best result that fits. The pixels never change during the search.&lt;/p&gt;

&lt;p&gt;But the fallback is deliberately different. In the compressor, when quality alone cannot reach the target, the tool shrinks the dimensions and tries again - the file size is the promise there, so pixels are negotiable. In the resizer the promise is reversed: the pixels are the whole point. So when the search cannot fit your KB limit at your exact dimensions, the tool does &lt;strong&gt;not&lt;/strong&gt; shrink anything. It hands you the smallest file it achieved at exactly the pixels you asked for, and says the limit was not met. Silently breaking the one number you typed in would be the worst possible failure mode.&lt;/p&gt;

&lt;p&gt;Two format gotchas carried over from the compressor, because they are still true:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. PNG cannot be squeezed.&lt;/strong&gt; PNG is lossless, so there is no quality to search - with a KB cap set, JPEG or WebP are the formats that can actually honour it. That is also why the tool defaults to "Keep original": its promise is pixels, not bytes, and re-encoding a PNG to JPEG just to satisfy a cap you did not ask about would be a nasty surprise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. JPEG fills transparency with white.&lt;/strong&gt; A transparent PNG exported as JPEG gets a white background painted in before the draw, because JPEG has nowhere to put an alpha channel - and white beats the black-background surprise a naive canvas export produces.&lt;/p&gt;

&lt;p&gt;One more honesty detail: upscaling is allowed. Set a width above the original and the tool will do it - but the new pixels are interpolated from the old ones, so the result is softer, never sharper, and the tool warns you instead of pretending otherwise.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it / break it
&lt;/h2&gt;

&lt;p&gt;The tool is here: &lt;a href="https://www.clicktoolset.com/p/image-resizer.html" rel="noopener noreferrer"&gt;Image Resizer&lt;/a&gt; - everything runs client-side, so view-source is the full documentation.&lt;/p&gt;

&lt;p&gt;If you find a target shape where Fill and crop trims something other than the edges, or a KB cap the search reports as met when the downloaded file is over it, I want to hear about it - the fit math and the borrowed search are exactly the kind of code that fails quietly.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is part of a series on building small, single-purpose web tools that run entirely in the browser. Next up: reading one exact pixel out of a photo - a colour picker with an 8x loupe, and what a photo's dominant colours are really made of.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>images</category>
      <category>canvas</category>
    </item>
    <item>
      <title>I Built an Image Compressor That Hits Exactly 50 KB (Not 'About 50 KB')</title>
      <dc:creator>Clicktoolset</dc:creator>
      <pubDate>Wed, 02 Dec 2026 08:48:47 +0000</pubDate>
      <link>https://dev.to/clicktoolset/i-built-an-image-compressor-that-hits-exactly-50-kb-not-about-50-kb-3dp5</link>
      <guid>https://dev.to/clicktoolset/i-built-an-image-compressor-that-hits-exactly-50-kb-not-about-50-kb-3dp5</guid>
      <description>&lt;p&gt;Every job portal, exam form and visa application has the same demand: your photo must be under 50 KB. Your phone hands you a 3 MB file. The gap between those two numbers is the whole problem - and most "compressors" solve it by guessing. Pick a quality slider, export, check the size, repeat. I wanted a tool that takes the target as an input and guarantees the output fits it.&lt;/p&gt;

&lt;p&gt;So I built one that runs 100% in the browser: drop in a photo, pick 50 KB (or 20, 100, 200, or any custom number), and it finds the highest quality that still fits. No server, no uploads, nothing leaves the page.&lt;/p&gt;

&lt;p&gt;Here is what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trick is a binary search, not a slider
&lt;/h2&gt;

&lt;p&gt;JPEG quality is a single number, and file size grows monotonically with it: higher quality always means a bigger file. That makes the problem a textbook binary search. Start with quality 0.05 and 0.92, probe the middle, and narrow the range toward the best quality that still fits under the target.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Simplified from the tool - real version wraps toBlob in a promise&lt;/span&gt;
&lt;span class="c1"&gt;// and repeats the search at smaller dimensions if quality alone can't fit.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fitToTarget&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.92&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bestQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;toBlob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;targetBytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;bestQ&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// fits - try a higher quality&lt;/span&gt;
      &lt;span class="n"&gt;lo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;hi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;            &lt;span class="c1"&gt;// too big - go lower&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;blob&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quality&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;bestQ&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seven rounds narrows the quality range from 0.87 wide to about 0.007 - precise enough that the result lands just under the target instead of far below it. That matters: a tool that always answers 50 KB with a 22 KB file has thrown away quality for nothing. The search keeps the best fitting result, not the last one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quality alone is not always enough
&lt;/h2&gt;

&lt;p&gt;A very detailed photo - foliage, crowds, sensor noise - can still be over 50 KB at the lowest usable quality. The fallback is to shrink the dimensions: 85%, then 72%, 61%, and so on, re-running the quality search at each step. Quality is always tried first, because a slightly smaller photo at good quality looks better than a full-size photo crushed to mush.&lt;/p&gt;

&lt;p&gt;There is a floor: the tool stops shrinking once either side drops below 120 pixels, and if even that cannot reach the target (it happens with PNG, see below), it says so plainly and shows the smallest size it achieved - instead of silently handing you a file that still fails the form.&lt;/p&gt;

&lt;h2&gt;
  
  
  PNG breaks the whole idea (and that is the interesting part)
&lt;/h2&gt;

&lt;p&gt;PNG is lossless. There is no quality setting to search - &lt;code&gt;toBlob&lt;/code&gt; ignores the quality argument entirely. So for PNG the tool skips the binary search and reaches the target purely by shrinking dimensions. That is also why the format choice matters: a PNG screenshot at 50 KB will be smaller in pixels than the same image as a JPEG, because JPEG can trade quality while PNG can only trade size.&lt;/p&gt;

&lt;p&gt;Two more format gotchas worth knowing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. JPEG has no transparency.&lt;/strong&gt; A PNG with a transparent background gets a white background when converted to JPEG, because JPEG simply has nowhere to put the alpha channel. The tool fills white before drawing, so you never get the black-background surprise that a naive canvas export produces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. GIF keeps only its first frame.&lt;/strong&gt; Animations do not survive a canvas round-trip, so the tool saves the first frame as a PNG and says so in the result. Pretending otherwise would be a worse bug than losing the animation.&lt;/p&gt;

&lt;h2&gt;
  
  
  A worked example
&lt;/h2&gt;

&lt;p&gt;A phone photo straight from the camera: 2,048 KB (2 MB), 4032 x 3024 pixels. Compressed to the 50 KB target, the result is at most 50 KB - 97.6% smaller than the original. Same subject, same framing. On a screen, or printed at passport size, the difference is hard to spot; the detail that went missing was mostly the kind your eye never registered in the first place.&lt;/p&gt;

&lt;p&gt;One more small honesty detail: if your image is &lt;em&gt;already&lt;/em&gt; under the target, the tool does not re-compress it at all. It tells you so and offers the original file unchanged. Re-encoding a file that already fits would only lose quality for no reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it / break it
&lt;/h2&gt;

&lt;p&gt;The tool is here: &lt;a href="https://www.clicktoolset.com/p/compress-image-to-50-kb.html" rel="noopener noreferrer"&gt;Compress Image to 50 KB&lt;/a&gt; — everything runs client-side, so view-source is the full documentation.&lt;/p&gt;

&lt;p&gt;If you feed it a photo where the result comes back far under the target, or where the quality search picks something visibly worse than a manual export at the same size, I want to hear about it - the search bounds (0.05 to 0.92, seven rounds) are exactly the kind of constants that deserve arguing about.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is part of a series on building small, single-purpose web tools that run entirely in the browser. Next up: the same engine, pointed at exact pixel sizes - an image resizer with social presets and an aspect lock.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>images</category>
      <category>canvas</category>
    </item>
    <item>
      <title>I Built a WCAG Color Contrast Checker That Runs Entirely in the Browser</title>
      <dc:creator>Clicktoolset</dc:creator>
      <pubDate>Sat, 28 Nov 2026 20:10:11 +0000</pubDate>
      <link>https://dev.to/clicktoolset/i-built-a-wcag-color-contrast-checker-that-runs-entirely-in-the-browser-21pf</link>
      <guid>https://dev.to/clicktoolset/i-built-a-wcag-color-contrast-checker-that-runs-entirely-in-the-browser-21pf</guid>
      <description>&lt;p&gt;Every developer has shipped text that &lt;em&gt;looked&lt;/em&gt; fine on their monitor and was unreadable for someone else. WCAG contrast ratios exist to take the guesswork out of that — but most checkers online are either buried in ads or ask you to install something.&lt;/p&gt;

&lt;p&gt;So I built one that runs 100% in the browser: pick a text color and a background color, and it instantly shows the contrast ratio, AA/AAA pass-fail badges for normal and large text, and a live preview. No server, no uploads, nothing leaves the page.&lt;/p&gt;

&lt;p&gt;Here is what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The formula is simpler than it looks
&lt;/h2&gt;

&lt;p&gt;A contrast ratio is just a comparison of &lt;strong&gt;relative luminance&lt;/strong&gt; — how bright a color actually appears, weighted the way human vision works (we are far more sensitive to green than to blue).&lt;/p&gt;

&lt;p&gt;For each sRGB channel, you first linearize it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;linearize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;channel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;channel&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;255&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mf"&gt;0.03928&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;12.92&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.055&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mf"&gt;1.055&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;luminance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.2126&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;linearize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.7152&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;linearize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.0722&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;linearize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;contrastRatio&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rgb1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rgb2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;l1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;luminance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rgb1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;luminance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rgb2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;lighter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;darker&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;l2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lighter&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;darker&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.05&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the entire engine. The &lt;code&gt;+ 0.05&lt;/code&gt; accounts for ambient light/screen flare, and it is why the maximum possible ratio is exactly &lt;strong&gt;21:1&lt;/strong&gt; (pure black on pure white) rather than infinity.&lt;/p&gt;

&lt;h2&gt;
  
  
  The thresholds you actually need to memorize
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Normal text&lt;/th&gt;
&lt;th&gt;Large text&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;AA&lt;/td&gt;
&lt;td&gt;4.5 : 1&lt;/td&gt;
&lt;td&gt;3 : 1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AAA&lt;/td&gt;
&lt;td&gt;7 : 1&lt;/td&gt;
&lt;td&gt;4.5 : 1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;"Large" means at least 24px, or at least ~18.7px if bold. AA is the level most regulations and audits target; AAA is the stricter, enhanced level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why #767676 is famous
&lt;/h2&gt;

&lt;p&gt;Run the numbers and you find that &lt;strong&gt;#767676 on white is 4.54:1&lt;/strong&gt; — it is the lightest gray that still passes AA for normal text. One step lighter and you fail. Designers have passed this hex around for years, and now you know it is not folklore, it is just arithmetic.&lt;/p&gt;

&lt;p&gt;A few more pairs I verified with the checker while building it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Text&lt;/th&gt;
&lt;th&gt;Background&lt;/th&gt;
&lt;th&gt;Ratio&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;#000000&lt;/td&gt;
&lt;td&gt;#FFFFFF&lt;/td&gt;
&lt;td&gt;21.00 : 1&lt;/td&gt;
&lt;td&gt;Passes everything&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#0A4450&lt;/td&gt;
&lt;td&gt;#FFFFFF&lt;/td&gt;
&lt;td&gt;10.74 : 1&lt;/td&gt;
&lt;td&gt;AAA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#FFFFFF&lt;/td&gt;
&lt;td&gt;#0E5A68&lt;/td&gt;
&lt;td&gt;7.83 : 1&lt;/td&gt;
&lt;td&gt;AAA&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#767676&lt;/td&gt;
&lt;td&gt;#FFFFFF&lt;/td&gt;
&lt;td&gt;4.54 : 1&lt;/td&gt;
&lt;td&gt;AA (barely)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;#FFFFFF&lt;/td&gt;
&lt;td&gt;#A9D94B&lt;/td&gt;
&lt;td&gt;1.65 : 1&lt;/td&gt;
&lt;td&gt;Fails everything&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That last one is the trap: a bright lime green &lt;em&gt;feels&lt;/em&gt; vibrant and modern, but white text on it is essentially unreadable in bright light — 1.65:1 fails even the large-text threshold by half. Flip it around (dark text #0D1F24 on the same lime) and you get 10.26:1, a AAA pass. Same brand color, opposite result — direction matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Two implementation details worth stealing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Test both directions.&lt;/strong&gt; A pair is not "accessible" or "inaccessible" — a &lt;em&gt;direction&lt;/em&gt; is. My UI always evaluates the exact foreground/background assignment the user picked, and swapping the colors is one click, because that is the most common fix.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Preview with real text sizes.&lt;/strong&gt; A ratio number is abstract; a preview paragraph at 16px and a heading at 24px make the pass/fail badges obvious. The badges map to the preview, not just to the number, so users see &lt;em&gt;why&lt;/em&gt; large text gets a pass at 3:1 while body text does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it / break it
&lt;/h2&gt;

&lt;p&gt;The tool is here: &lt;a href="https://www.clicktoolset.com/p/color-contrast-checker.html" rel="noopener noreferrer"&gt;Color Contrast Checker&lt;/a&gt; — everything runs client-side, so view-source is the full documentation.&lt;/p&gt;

&lt;p&gt;If you test it against a pair you know from another checker and get a different second decimal, I want to hear about it — rounding in the linearization step is exactly the kind of bug that hides in these tools.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This is part of a series on building small, single-purpose web tools that run entirely in the browser. Next up: compressing an image to an exact file size (50 KB, not "about 50 KB") with a binary search over JPEG quality.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>a11y</category>
      <category>css</category>
    </item>
    <item>
      <title>How to Choose Colors for a Website: A Practical Guide</title>
      <dc:creator>Clicktoolset</dc:creator>
      <pubDate>Sat, 17 Oct 2026 21:09:30 +0000</pubDate>
      <link>https://dev.to/clicktoolset/how-to-choose-colors-for-a-website-a-practical-guide-e63</link>
      <guid>https://dev.to/clicktoolset/how-to-choose-colors-for-a-website-a-practical-guide-e63</guid>
      <description>&lt;p&gt;Choosing colors for a website can be harder than it looks. A color palette needs to feel consistent, keep text readable, and support the purpose of the design.&lt;/p&gt;

&lt;p&gt;Here is a simple process you can use for your next project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start with a Primary Color&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Choose one color that represents the overall mood of your website.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Blue can feel dependable and professional.&lt;/p&gt;

&lt;p&gt;Green can suggest growth or nature.&lt;/p&gt;

&lt;p&gt;Orange can create a sense of energy.&lt;/p&gt;

&lt;p&gt;Purple can give a design a creative feel.&lt;/p&gt;

&lt;p&gt;These are common associations, not fixed rules. The right choice depends on your audience and context.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a Small Color Palette&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You do not need dozens of colors. Start with a few practical roles:&lt;/p&gt;

&lt;p&gt;Primary: The main brand or interface color.&lt;/p&gt;

&lt;p&gt;Secondary: A supporting color for variety.&lt;/p&gt;

&lt;p&gt;Background: A color that keeps the layout comfortable to read.&lt;/p&gt;

&lt;p&gt;Text: A color with strong contrast against the background.&lt;/p&gt;

&lt;p&gt;Accent: A color for important actions or selected elements.&lt;/p&gt;

&lt;p&gt;A limited palette is usually easier to apply consistently across buttons, cards, headings, and backgrounds.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check Contrast and Readability&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A color combination may look attractive but still make text difficult to read.&lt;/p&gt;

&lt;p&gt;Check the contrast between text and its background, especially for small text and buttons. WCAG guidance generally recommends a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text.&lt;/p&gt;

&lt;p&gt;Do not rely on color alone to communicate information. Use labels, icons, or other visual cues when necessary.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Test Colors Together&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;View your colors in context rather than judging each swatch separately. Try them on a sample button, a heading, and a card.&lt;/p&gt;

&lt;p&gt;You can use a color palette tool to explore combinations, compare shades, and refine your choices before applying them to a full design.&lt;/p&gt;

&lt;p&gt;For a quick starting point, explore &lt;a href="https://www.clicktoolset.com/" rel="noopener noreferrer"&gt;Clicktoolset&lt;/a&gt; and its color tools.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep the Palette Consistent&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you settle on a palette, reuse the same colors for the same purposes. For example, keep primary buttons consistent and reserve accent colors for elements that deserve attention.&lt;/p&gt;

&lt;p&gt;Documenting your colors as HEX values also makes it easier to reuse them in CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nt"&gt;root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nv"&gt;--color-primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#2563EB&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--color-secondary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#14B8A6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--color-background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#F8FAFC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--color-text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#1E293B&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nv"&gt;--color-accent&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#F59E0B&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These values are only an example. Test your actual combinations for contrast and suitability before using them in a project.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;/p&gt;

&lt;p&gt;A useful website palette does not have to be complicated. Start with a primary color, add a few supporting roles, check readability, and test the result in a real layout.&lt;/p&gt;

&lt;p&gt;A small, consistent palette is often easier to maintain than a collection of unrelated colors.&lt;/p&gt;

</description>
      <category>design</category>
      <category>ui</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
