Bespoke Web App Development: HTML colours

Bespoke Web App Development: HTML colours

HTML uses the American spelling of colour, color. HTML colors are used to define the colors of the text, backgrounds, borders, and other elements of an HTML document. Colors in HTML can be specified using different methods:

  1. Color Names: HTML defines a set of predefined color names that can be used to specify colors. For example, "red", "green", "blue", "black", etc.

  2. Hexadecimal Notation: Colors can also be specified using hexadecimal values, which consist of a hash (#) followed by a six-digit code representing the amount of red, green, and blue in the color. For example, #FF0000 is pure red, #00FF00 is pure green, and #0000FF is pure blue.

  3. RGB Notation: Colors can be specified using the RGB (Red, Green, Blue) color model, which uses three values between 0 and 255 to represent the amount of red, green, and blue in the color. For example, #ff0000 is pure red, #00ff00 is pure green, and #0000ff is pure blue.

  4. RGBA Notation: RGBA is similar to RGB, but with an additional parameter for transparency (alpha), which is represented as a value between 0 (fully transparent) and 1 (fully opaque). For example, rgba(255,0,0,0.5) is a semi-transparent red color.

Here's an example of how to use color in HTML:

html
<p style="color: red">This text is red</p> <div style="background-color: #00FF00">This div has a green background</div> <span style="border: 1px solid #0000ff">This span has a blue border</span>

In this example, we use the style attribute to set the color, background-color, and border properties using the different color notation methods.


In HTML, colors can be specified using color names, hexadecimal values, or RGB values.

  1. Color names: HTML has a set of predefined color names that can be used in the "color" attribute of HTML tags. For example, "red", "blue", "green", "yellow", "white", "black", etc.

  2. Hexadecimal values: Colors can also be specified using hexadecimal values. A hexadecimal value is a six-digit code that represents the amount of red, green, and blue in a color. The code begins with a hash (#) followed by six digits. Each pair of digits represents the intensity of red, green, and blue respectively. For example, #FF0000 represents pure red, #00FF00 represents pure green, and #0000FF represents pure blue.

  3. RGB values: RGB stands for Red, Green, Blue. RGB values are another way to specify colors in HTML. The values are written in the format rgb(red, green, blue), where red, green, and blue are integers between 0 and 255 that represent the amount of red, green, and blue in the color respectively. For example, #ff0000 represents pure red, #00ff00 represents pure green, and #0000ff represents pure blue.

There are also other color models available, such as HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value), that can be used to specify colors in HTML.

Read more about HTML colours