0

I have six digit random number like 1424517,1420422 and so on. Is there any way to use this number to make html color code and i used it as background:#1424517 to make some background color.

Domi
  • 22,151
  • 15
  • 92
  • 122

3 Answers3

1

CSS color codes are 8bit-RGB by default. I assume, you have a single 24-bit number. You can simply convert it to a CSS color code, by formatting it as hexadecimal.

If you have 3 8-bit numbers, you can construct a number like this:

color = (val1 % 256, val2 % 256, val3 % 256);

Where "%" is the modulo operator.

Community
  • 1
  • 1
Domi
  • 22,151
  • 15
  • 92
  • 122
0

I am not sure what exactly you are asking, but I'm assuming that you want to randomly select a color for a webpage. Colors are done in RGB Hexadecimal typically, ranging from #000000 (black) to #FFFFFF (white). #0000FF would be pure blue, #00FF00 would be pure green, and #FF0000 would be pure red. By changing the values you will have different colors. You could always generate a random number between 0 and 16777215 (256^3-1) and convert that to hex.

Don
  • 87
  • 6
0

html color codes can be in 3 formats:

  • hex value(#123abc)
  • rgb which ranges from 0-255, rgb(100,100,100), and
  • direct name of the colors(eg: red, green blue)

Refer http://www.w3schools.com/html/html_colors.asp