How to Find the Hex Code of Any Color on a Website (4 Methods)

Featured graphic for “How to Find the Hex Code of Any Color on a Website (4 Methods)” showing color swatches and codes

You spot a color you love on a website: a button, a header, a brand accent. Now you want the exact code so you can use it in your own design, match a client’s brand or build a palette around it. Guessing by eye rarely works. Two blues that look the same on screen can be several shades apart in code.

The good news is that you can almost always find it. Colors set in the page’s CSS, such as text, buttons and backgrounds, are stored as values you can read directly. Colors inside images, photos and videos aren’t stored as CSS values, but you can still read them pixel by pixel. This guide shows four reliable ways to find the hex code of any color on a website, from a two-click browser trick to methods that work on images, gradients and phones. It also explains why the code you find sometimes looks slightly “off”, and how to get the right one.

Quick answer: the fastest way

If you use Chrome or Edge on a computer, this takes about ten seconds:

  1. Right-click the colored element and choose Inspect.
  2. In the Styles panel, click the small color square next to the color value. The color picker opens.
  3. Click the eyedropper icon in the color picker to activate it.
  4. Click the exact pixel you want anywhere on the page. Its hex code appears in the picker.

If you don’t want to open developer tools at all, use an online screen color picker instead (Method 4). It works in the browser and needs no install.

Method 1: Use the browser eyedropper

Modern browsers have an eyedropper built into their developer tools. It reads the color of the exact pixel under your cursor, so it works on text, buttons, backgrounds, icons and even images.

Chrome DevTools color picker

  1. Right-click anywhere on the page and choose Inspect (or press F12, or Ctrl+Shift+I on Windows / Cmd+Option+I on Mac).
  2. In the Elements tab, look at the Styles panel on the right. Find any rule that contains a color, such as color, background-color or border-color.
  3. Click the small colored square next to the value. A color picker opens.
  4. Click the eyedropper icon in the picker (or press C). Your cursor becomes a magnifier.
  5. Click the color you want anywhere on the page. The picker now shows that color.
  6. If the value isn’t in hex, use the display value switcher in the picker to choose HEX, or Shift-click the color square to open a drop-down list of color formats and pick hex from it.

One caution: sampling a new color changes the CSS value in DevTools for that session. That change happens only in your browser and disappears when you reload, but don’t copy it back as the element’s “real” color by mistake.

Chrome also has a CSS Overview panel (open the DevTools menu, then More tools > CSS Overview). Capture an overview and it lists the colors used in the CSS of the page you have open, grouped by type such as text and background. Click a swatch to see which elements use it. It covers only that one page, not every page on the site, and colors inside images aren’t included. Google describes it as a preview feature, so its options may change.

Firefox eyedropper

Firefox offers its eyedropper in two places, and they behave differently.

Standalone Eyedropper (copies the color value):

  1. Open Firefox’s Browser Tools menu (in the main menu, under More tools) and choose Eyedropper. You can also click the eyedropper button in the Page Inspector’s toolbar.
  2. Move over the page. A magnified view shows the pixel and its color value.
  3. Click to copy that color value to your clipboard.

Eyedropper inside the Page Inspector (changes a CSS value):

  1. Right-click the element and choose Inspect.
  2. In the Rules view, click the small color sample next to a color value. A color picker opens.
  3. Click the eyedropper icon in that picker, then click a color on the page.

This version doesn’t copy anything. It sets the color in the Rules view to the color you clicked, only in your browser, until you reload. Use the standalone Eyedropper when you just want the code.

Microsoft Edge

Edge is built on the same engine as Chrome, so its DevTools work the same way. Press F12, find a color value in the Styles panel, click its color square and use the eyedropper.

Safari

Safari’s Web Inspector shows color values in its Styles sidebar, but it is turned off by default. To enable it, choose Safari > Settings, open the Advanced pane and check Show features for web developers. Then right-click an element and choose Inspect Element.

To sample any pixel on a Mac, you can also use Apple’s built-in Digital Color Meter app (search for it with Spotlight). It shows the color values under your cursor. Choose View > Display Values to change how the values are shown. Depending on your macOS version, this may show RGB numbers rather than a hex code; if so, convert the three values to hex with a color converter.

Method 2: Inspect the element and read its CSS

The eyedropper reads pixels. Inspecting reads the actual code the designer wrote, which is usually more accurate for flat colors like text and buttons.

Find the color property

  1. Right-click the element and choose Inspect.
  2. The element is highlighted in the Elements panel. In Styles, look for these properties:
What you wantCSS property to look for
Text colorcolor
Backgroundbackground-color or background
Button or card outlineborder-color or border
Icon (SVG)fill or stroke
Shadowbox-shadow

If you can’t find it in Styles, switch to the Computed tab. It shows the final value the browser actually uses, after all the rules are applied.

You may see a value like var(–primary) instead of a color. That is a CSS variable. Hover over it or check the Computed tab to see the real value behind it.

Convert rgb() or hsl() to hex

The Computed tab usually shows colors as rgb(), and some sites write colors in hsl(). These are the same color in a different format. For example, all three of these are identical:

FormatValue
RGBrgb(34, 115, 195)
HSLhsl(210, 70%, 45%)
HEX#2273C3

To convert, Shift-click the color square in Chrome DevTools and choose hex from the format list, or paste the value into a color converter. Each pair of hex digits is one RGB channel in base 16: 34 = 22, 115 = 73 and 195 = C3.

Method 3: Take a screenshot and use an image color picker

Sometimes the color isn’t in the CSS at all. It might be part of a photo, a logo saved as an image, a video frame or a banner graphic. DevTools can’t read a value that doesn’t exist in the code, but an image color picker can read the pixels.

  1. Take a screenshot of the area you need. On Windows, press Win+Shift+S. On a Mac, press Cmd+Shift+4 and drag over the area.
  2. Open an image color picker and upload the screenshot.
  3. Click the exact spot you want. The tool shows the hex code, plus RGB and HSL values.

This method also works when you can’t use developer tools: on a phone or tablet, inside an app, or with a PDF. Take the screenshot on that device, then open it in the image color picker.

Zoom in before you click. Edges of text and icons are blended with the background (this is called anti-aliasing), so a pixel on the edge gives you a mixed color. Click near the center of a solid area instead.

For more ways to pull colors out of photos and graphics, see our guide to finding the color of an image.

Method 4: Use an online screen color picker (no install)

If you don’t want to open developer tools or take screenshots, a screen color picker samples colors directly from your screen in the browser.

  1. Open the Screen Color Picker in a supported desktop browser.
  2. Click the button to start picking. Your cursor turns into an eyedropper.
  3. Switch to the website you want to sample and click the color.
  4. The hex code appears with its RGB and HSL values, ready to copy.

Because it reads your screen, it can sample colors outside the browser too, such as a design app or an image viewer. Browser support for screen picking varies, so if the button isn’t available, use Method 1 or Method 3.

On Windows, Microsoft’s free PowerToys app also includes a system-wide Color Picker that copies colors in HEX by default (press Win+Shift+C once it is enabled). On a Mac, Digital Color Meter can read screen colors too.

Which method should you use?

SituationBest methodWhy
Text, buttons, flat backgroundsMethod 2: InspectReads the exact value from the code
Any visible pixel, quicklyMethod 1: DevTools eyedropperNo screenshots needed
All CSS colors on one pageChrome CSS Overview (Method 1)Lists the CSS colors of the open page at once
Photos, logos saved as images, videoMethod 3: Screenshot + image pickerThe color isn’t in the CSS
Phone, tablet, app or PDFMethod 3: Screenshot + image pickerNo developer tools available
No developer tools, desktopMethod 4: Screen color pickerWorks in the browser, no install

Colors with transparency

Some colors are written with an alpha (opacity) value, such as rgba(34, 115, 195, 0.5). Hex codes can store opacity too, with two extra digits at the end. The 8-digit hex version of that color is #2273C380: the last two digits, 80, mean about 50% opacity.

OpacityAlpha hex digitsExample
100%FF#2273C3FF (same as #2273C3)
75%BF#2273C3BF
50%80#2273C380
25%40#2273C340
0%00#2273C300 (fully transparent)

Here is the important part: a transparent color looks different depending on what is behind it. If you sample it with an eyedropper, you get the blended result, not the original color. To copy the color exactly as written, inspect the CSS (Method 2) instead.

Why the hex code can look different

You sample a color, paste the hex code into your own design, and it doesn’t quite match. This is common, and there is almost always a simple reason.

Gradients and images

A gradient changes color across its whole length, so every pixel has a slightly different code. An eyedropper gives you just one point on that gradient. To get the real start and end colors, inspect the CSS. Look for background-image: linear-gradient(…), which lists every color stop.

Photos work the same way. A “red” product in a photo is made of hundreds of slightly different reds, and compressed JPEG images add small color shifts of their own. Sample several spots and choose the one that represents the color best.

Opacity and overlays

If an element is semi-transparent, or sits under a tinted overlay, what you see is a blend. The eyedropper reads the blend; the CSS holds the original. A white button at 80% opacity on a blue background will sample as a pale blue, not white.

Hover, focus and active states

Many buttons and links change color when you hover over them or click them. If you sample while your mouse is on the button, you may get the hover color instead of the normal one. In Chrome DevTools, the :hov button in the Styles panel lets you force a state (such as :hover) so you can read each color separately.

Color profiles and screens

Screens don’t all display color the same way. Wide-gamut displays, such as many recent Macs and phones, can show more saturated colors than a standard monitor. Some screenshot tools also attach a color profile that shifts values slightly. Chrome’s eyedropper also samples in the standard sRGB color space, so a wider-gamut color is clipped to the nearest sRGB match. When the exact code matters, for example for brand colors, trust the value in the CSS over a sampled pixel.

How designers, developers and site owners use this

  • Designers match a client’s existing brand colors when the client has no brand guide. Inspect the logo, buttons and headings, then save the codes into a palette.
  • Developers check that a live site uses the exact colors from the design file, and track down where a stray color comes from.
  • Website owners and marketers keep social graphics, emails and ads consistent with the website by reusing its exact codes.
  • Everyone can check readability. Once you have the text and background colors, test them for contrast before you reuse them.

Common mistakes to avoid

  1. Sampling the edge of text or an icon. Edge pixels are blended with the background. Fix: zoom in and sample the center of a solid area, or read the CSS value instead.
  2. Copying the hover color by accident. Fix: move your mouse away before sampling, or use the :hov toggle in DevTools.
  3. Using a sampled color from a gradient as a “flat” brand color. Fix: read the gradient’s color stops in the CSS.
  4. Ignoring transparency. A sampled color from a semi-transparent element is a blend. Fix: inspect the CSS for rgba() or 8-digit hex values.
  5. Mixing up formats. rgb(34, 115, 195) and #2273C3 are the same color, but pasting one into a field that expects the other can fail. Fix: convert to the format your tool needs.
  6. Trusting a screenshot from a different screen. Color profiles can shift values. Fix: for exact brand colors, use the CSS value.
  7. Assuming a website’s color is free to use as a trademark. Reading a hex code is fine, but copying another company’s whole brand identity can cause problems. Fix: use found colors for inspiration and matching your own work.

If you want a refresher on picking and adjusting colors once you have a code, our online color picker guide walks through it.

FAQ

How do I find the hex code of a color on my phone?

Mobile browsers don’t include developer tools. Take a screenshot of the page, then open it in an image color picker and tap the color you need.

How do I get the hex code from a logo?

If the logo is an SVG, inspect it and look for fill or stroke values in the CSS or SVG code. If it is a PNG or JPG image, take a screenshot or download it and use an image color picker on a solid part of the logo.

How do I find a color code in a PDF?

Take a screenshot of the PDF page and use an image color picker. For print documents, the result is the screen (RGB) version of the color, which may differ slightly from the printed CMYK color.

Why does the eyedropper give a slightly different value than the CSS?

Usually because of anti-aliased edges, transparency, overlays, gradients or your screen’s color profile. The CSS value is the color the designer specified; the eyedropper shows what your screen displays.

Can I find all the colors used on a web page at once?

Yes. In Chrome, open DevTools, then the menu, More tools > CSS Overview, and capture an overview. It lists the CSS colors used on the page you have open, grouped by type. Check other pages separately, and use an image color picker for colors inside images.

What is the difference between hex and RGB?

They describe the same color in different notation. RGB lists red, green and blue as numbers from 0 to 255. Hex writes the same three numbers in base 16, as a six-digit code.

Do I need to install anything?

No. Browser DevTools are built in, and online screen and image color pickers run in your browser.

Find your color now

The quickest route depends on where the color lives. For flat colors in the page code, inspect the element. For any pixel on screen, use an eyedropper. For images, phones and PDFs, take a screenshot and use an image color picker. Whichever you choose, check the result for contrast before you use it in your own design.

Scroll to Top