significance of using # in hex code because my code also ran without using # and having the same output?

Hex code is preceded by a pound or hash sign ‘#’. # is used to represent hex. A hex code is a 6 digit representation of a color. It only represents that the code is combination of 6 digits and has no other significance.

It’s basically an indication of the six digit code used other than that it has no mere significance.

Hiii @jain.reechika

HEX define a combination 6 digit number from 0 to 9 and letters from A to F.

When we use HEX code in our program then it necessary to write # before our color code,

without write # our program will be working but output can not change according our input.

Hi,

In our daily life we use decimal system which uses base 10. As in we have 10 unique types of digits (0 to 9) and after a number exceeds a maximum individual digit, the digit on it’s left is increased by 1, while the current digit is set to the lowest valued digit (generally 0). For example after 9 we have 10, after 19 we have 20, after 199 we have 200.

In computer programming, you can write numbers with different base. The most commonly used is binary which has a base 2, for after 1 you get 10 (2 in decimal), after 11 (3 in decimal) you get 100(4 in decimal) and so forth.

Other types of representations take base 8 known as octal, after 7 you have 10, and HEX which has a base 16 after 9 you have A to F, and after F you have 10 (16 in decimal).

When you write the character # next to a number, it is interpreted as HEX by the computer. IF you used the character ‘o’ then the number is taken as base 8 or octal. Similary if you used the letter ‘d’ you get decimal or base 10 which is the default if you don’t use a letter, and ‘b’ for binary or base 2.

So if you write the number 100 as ‘100’ it means 100 in normal human usage. But if you write the number as “#100” then it actually means 256.

So a color code with # and without # are different.

Hello this is Sheikh Sajid,

These URL will surely help you

In hexadecimal system range is from (0 to 9 and then A to F)

where A=10,B=11,C=12,D=13,E=14,F=15

Your code is running without using #,I think haven’t refresh the page

then check…

Hi,

There is a difference between #200 and 200 , The meaning of #200 is it represent hex code .

if u got the same output with and without using # , then it doesn`t mean that every time you will get required output.

A hexadecimal color is specified with: #RRGGBB.

RR (red), GG (green) and BB (blue) are hexadecimal integers between 00 and FF specifying the intensity of the color.

A “HEX color” is expressed as a six-digit combination of numbers and letters defined by its mix of red, green and blue (RGB). #RRGGBB.

Yes it might work in few compilers without using “#” symbol. It’s better to use the symbol.

Hi @jain.reechika ,

Basically a hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and BB (blue) hexadecimal integers specify the components of the color.

If # is not used to represent hex value the default browser will automatically add the # to it. But not all browsers support this thing.