ArticleslgStudy

science

Web colors

Web colors is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Web colors rather than just read about it. In short: Web colors, also known as hex codes and color codes, are colors used in displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB triplet, in hexadecimal format (a hex triplet) or according to its common English name in some cases. A color tool or other graphics software is often used to generate color values.

Web colors — main illustration
Web colors — illustration

Key takeaways

  • Web colors belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Web colors to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Web colors from memory before moving on to harder problems.

Reference excerpt

Web colors, also known as hex codes and color codes, are colors used in displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB triplet, in hexadecimal format (a hex triplet) or according to its common English name in some cases. A color tool or other graphics software is often used to generate color values. In some uses, hexadecimal color codes are specified with notation using a leading number sign (#). A color is specified according to the intensity of its red, green and blue components, each represented by eight bits. 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. In hexadecimal, these are specified with two hexadecimal digits per color, leading to a total of six hexadecimal digits. In some contexts, it is possible to specify two more place values, which provide a transparency (alpha) channel. Colors 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. Specifying a non-sRGB color this way requires the RGB() function call. It is impossible with the hexadecimal syntax (and thus impossible in legacy HTML documents that do not use CSS). 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. 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. 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. User agents vary in the fidelity with which they represent the specified colors. More advanced user agents use color management to provide better color fidelity; this is particularly important for Web-to-print applications.

Hex triplet A hex triplet is a six-digit, three-byte, hexadecimal number used in HTML, CSS, SVG, and other computing applications to represent colors. The bytes represent the red, green, and blue components of the color. A fourth byte can optionally be included for the alpha channel, making an eight-digit number. One byte represents a number in the range 00 to FF (in hexadecimal notation), or 0 to 255 in decimal notation. This represents the lowest (0) to the highest (255) intensity of each of the color components. Thus web colors specify colors in the 24-bit RGB color scheme. The hex triplet is formed by concatenating three bytes in hexadecimal notation, in the following order:

Byte 1: red value (color type red) Byte 2: green value (color type green) Byte 3: blue value (color type blue) Byte 4: alpha value (transparency, optional) For example, consider the color where the red/green/blue values are decimal numbers: red=123, green=58, blue=30 (a hardwood brown color). The decimal numbers 123, 58, and 30 are equivalent to the hexadecimal numbers 7B, 3A, and 1E, respectively. The hex triplet is obtained by concatenating the six hexadecimal digits together, 7B3A1E in this example. If any one of the three color values is less than 10 hex (16 decimal), it must be represented with a leading zero so that the triplet always has exactly six digits. For example, the decimal triplet 4, 8, 16 would be represented by the hex digits 04, 08, 10, forming the hex triplet 040810. The number of colors that can be represented by this system is 2563, 166, or 224 = 16,777,216.

Shorthand hexadecimal form An abbreviated, three (hexadecimal)-digit or four-digit form can be used, but can cause errors if software or maintenance scripts are only expecting the long form. Expanding this form to the six-digit form is as simple as repeating each digit: 09C becomes 0099CC as presented on the following CSS example:

This shorthand form reduces the palette to 4,096 colors, equivalent of 12-bit color as opposed to 24-bit color using the whole six-digit form (16,777,216 colors). This limitation is sufficient for many text-based documents.

Converting RGB to hexadecimal

RGB values are usually given in the 0–255 range; if they are in the 0–1 range, the values are multiplied by 255 before conversion. This number divided by sixteen (integer division; ignoring any remainder) gives the first hexadecimal digit (between 0 and F, where the letters A to F represent the numbers 10 to 15. See hexadecimal for more details). The remainder gives the second hexadecimal digit. For instance, the RGB value 58 (as shown in the previous example of hex triplets) divides into 3 groups of 16, thus the first digit is 3. A remainder of ten gives the hexadecimal number 3A. Likewise, the RGB value 201 divides into 12 groups of 16, thus the first digit is C. A remainder of nine gives the hexadecimal number C9. This process is repeated for each of the three color values. Conversion between number bases is a common feature of calculators, including both hand-held models and the software calculators bundled with most modern operating systems. Web-based tools specifically for converting color values are also available.

HTML color names

Recent W3C specifications of color names distinguish between basic and extended colors. In HTML and XHTML, colors can be used for text, background, frame borders, tables, and individual table cells.

Basic colors The basic colors are 16 colors defined in the HTML 4.01 specification, ratified in 1999, as follows (defined case-insensitive):

These 16 were labeled as sRGB and included in the HTML 3.0 specification, which noted they were "the standard 16 colors supported with the Windows VGA palette."

Extended colors

… excerpt ends here. Continue reading the full article.

Illustrations

Web colors: SVG Version of X11 color names
SVG Version of X11 color names
Web colors illustration

Worked examples

Example 1 — a first encounter with Web colors

Start with the simplest possible case. Write down what Web colors claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Web colors before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Web colors ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Web colors

In research
Web colors appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Web colors in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Web colors is common in secondary-school and first-year university syllabi. It links to neighbouring topics Color, Web colors, Web design, so understanding it makes those chapters shorter.
In everyday life
Look for Web colors outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Web colors” →

How to study Web colors in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Web colors means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Web colors out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Web colors in simple terms?

Web colors, also known as hex codes and color codes, are colors used in displaying web pages on the World Wide Web; they can be described by way of three methods: a color may be specified as an RGB triplet, in hexadecimal format (a hex triplet) or according to its common English name in some cases…

Why does Web colors matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Web colors?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Web colors.

Tags

  • Color
  • Web colors
  • Web design

Keep exploring