

This represents the least (0) to the most (255) intensity of each of the color components. One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. The bytes represent the red, green, and blue components of the color. More advanced user agents use color management to provide better color fidelity this is particularly important for Web-to-print applications.Ī hex triplet is a six-digit, three- byte hexadecimal number used in HTML, CSS, SVG, and other computing applications to represent colors. User agents vary in the fidelity with which they represent the specified colors. These have been chosen to be similar to many real-world monitors and viewing conditions, to allow rendering to be fairly close to the specified values even without color management. Web colors have an unambiguous colorimetric definition, sRGB, which relates the chromaticities of a particular phosphor set, a given transfer curve, adaptive whitepoint, and viewing conditions. The first versions of Mosaic and Netscape Navigator used the X11 color names as the basis for their color lists, as both started as X Window System applications. It is impossible with the hexadecimal syntax (and thus impossible in legacy HTML documents that do not use CSS). Specifying a non-sRGB color this way requires the RGB() function call. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified.Ĭolors outside the sRGB gamut can be specified in Cascading Style Sheets by making one or more of the red, green and blue components negative or greater than 100%, so the color space is theoretically an unbounded extrapolation of sRGB similar to scRGB. A color is specified according to the intensity of its red, green and blue components, each represented by eight bits.

In some uses, hexadecimal color codes are specified with notation using a leading number sign (#).

A color tool or other graphics software is often used to generate color values. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names in some cases.

You used the BGHEX() function to generate the Hexadecimal codes of all the colors in Google Sheets' color picker.Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors. In this tutorial you learned how to write a custom function BGHEX() that returns the Hexadecimal code of a cell's background color. The table below lists all of the 80 colors in the color picker along with their names and Hex codes. Hex codes of all the colors in Google Sheets' color picker The result should be a spreadsheet like the one below. Use the formula to generate Hex codes for all of the colors in the color picker. Step 4 - Populate the HEX codes for all the colors in the color picker Use the BGHEX() function in your spreadsheet to get the Hex code of any cell's background color.įor example, entering the formula =BGHEX(ROW(B1), COLUMN(B1)) results in the Hex code #000000, which is the Hex code for the color black. Step 3 - Use the function to populate the HEX codes in the spreadsheet Therefore, just knowing the value contained in the cell will not work and we need to explicitly tell the function the coordinates of the cell. In this case, the function needs to know the coordinates of the cell in order to extract its background color. So, the function will not know which cell or range the values came from. When you call a custom function with a cell or a range as input, only the values in the cell or range are passed to the function. Why do we need to pass the row and column coordinates to the custom function? Why not just reference the cell directly like you would in other functions? The function takes the row and column coordinates of a single cell and it returns the background color of the cell. The above code creates a custom function that you can use from your spreadsheet like any other built-in function. Var background = SpreadsheetApp.getActive().getDataRange().getCell(row, column).getBackground() * The Hexadecimal value of the cell's background color. * Returns the Hexadecimal value of a cell's background color. Open the script editor from the Tools menu (Tools -> Script editor) and replace the code in the editor with the code below. Step 1 - Create a Google Sheets spreadsheet and fill a couple of cells with different colors Step 2 - Write a Custom Function to return the HEX code of a cell's background color You know how to create a Custom Function using Google Apps Script. You're familiar with HTML color codes: What they are and how to use them. You're familiar with the basics of Google Sheets. In this tutorial, I'll show you how to get the Hexadecimal codes (also known as HTML color codes) of the colors in Google Sheets' color picker. How to get the Hexadecimal codes of colors in Google Sheets
