banner
Welcome to HTML.co.uk, the number one resource for all news, information, and happenings regarding HTML.

Updates: HTML.co.uk has just been relaunched. Subscribe to our RSS Feed to stay on top of HTML news and techniques.
Dec
29th

Help Understanding HTML Colour Codes

Author: Editor | Files under HTML Tutorials
Tags for this article: , , , ,

Whenever dealing with web pages, it is always better to edit the HTML directly rather than relying on the programmes such as Adobe GoLive or Microsoft Front Page for the Layout of the web pages. One of the major issues for almost all the web designers is to understand as to what exactly the HTML Colour code means and exactly to use them. To explain it better, HTML colour codes can be described as six character wide colour codes for example #80FF12.

The next obvious question is going to be how can a colour be described by numbers?

The simplest method adopted by the computers is to mix all the specified values of Blue, Green and Red which have been mixed together for achieving the desired colours. As and when you keep on varying the quantities of these basic colours, almost any colour can be created.

Why do the colours and their corresponding numbers relate to the computers?

All display devices such as an LCD television, or Computer Display, make use of the pixels for displaying everything what is viewed on the screen. These pixels have their colour values specified in Red, Blue and Green or RBG value. To understand this better, let us take a simple example. If the resolution of your PC monitor is set to 1024 x 768 resolution, this means that there are 768 lines which are running across your PC screen from top to bottom and each line consists of 1024 little dots or pixels in it. And, surprisingly each pixel or small dot is further made up of light sources or smaller dots, which are red, blue and green.

How are these RGB colour values represented by computers?

RGB values are stored by the computers as three separate values and each one in the rage between 0 – 255. And if you consider 0 also a value then there will be 256 values. And when these values of Red, Blue and Green are combined to get a colour, you have the option of (256 x 256 x 256) 16.7 million colours available for you. These are considered to be true colours by almost all the people as they can represent almost all the images and photographs quite naturally and accurately.

But what is a Hex Value?

Most of the computers store all the information in the form of 0s and 1s. Each of this tiny or single value is referred to as bit. Eight of these bits combine to make a byte. In maths we use the base 10 decimal, when we use 0 and 1, we take it to the base 2 or binary but in computers we take it to the base 16 of hexadecimal. Hex uses 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. For example if we want to represent 128, in Hex, it will be simply represented in 2 digits, 80. Therefore by making use of hex values in HTML and other programming languages, we actually end up saving a lot of space.

How is it related to HTML colour codes?

As a matter of fact, HTML colour codes are made up of three sets of hexadecimal numbers, one for red, one for blue and one for green.

For example, 000000 would represent black where Red, Blue and Green values are all zeros.

Similarly, FFFFFF would represent white where all the three colours have 255 values.

FF0000 will be all red where red has the value 255 and the remaining two blue and green will have value 0

00FF00 will be Blue and so on.

Hopefully this will help you in understanding the colour codes in HTML and how are they saved in the computers.

Post a Comment