Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:21:54+00:00 2026-05-27T06:21:54+00:00

Why do certain random strings produce colors when entered as background colors in HTML?

  • 0

Why do certain random strings produce colors when entered as background colors in HTML?

For example, bgcolor="chucknorris" produces a red background:

<body bgcolor="chucknorris"> test </body>

Conversely, bgcolor="chucknorr" produces a yellow background:

<body bgcolor="chucknorr"> test </body>

This holds true across various browsers and platforms. What’s going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:21:55+00:00Added an answer on May 27, 2026 at 6:21 am

    It’s a holdover from the Netscape days:

    Missing digits are treated as 0[…]. An incorrect digit is simply interpreted as 0. For example the values #F0F0F0, F0F0F0, F0F0F, #FxFxFx and FxFxFx are all the same.

    It is from the blog post A little rant about Microsoft Internet Explorer’s color parsing which covers it in great detail, including varying lengths of color values, etc.

    If we apply the rules in turn from the blog post, we get the following:

    1. Replace all nonvalid hexadecimal characters with 0’s:

      chucknorris becomes c00c0000000
      
    2. Pad out to the next total number of characters divisible by 3 (11 → 12):

      c00c 0000 0000
      
    3. Split into three equal groups, with each component representing the corresponding colour component of an RGB colour:

      RGB (c00c, 0000, 0000)
      
    4. Truncate each of the arguments from the right down to two characters.

    Which, finally, gives the following result:

    RGB (c0, 00, 00) = #C00000 or RGB(192, 0, 0)
    

    Here’s an example demonstrating the bgcolor attribute in action, to produce this “amazing” colour swatch:

    <table>
      <tr>
        <td bgcolor="chucknorris" cellpadding="8" width="100" align="center">chuck norris</td>
        <td bgcolor="mrt"         cellpadding="8" width="100" align="center" style="color:#ffffff">Mr T</td>
        <td bgcolor="ninjaturtle" cellpadding="8" width="100" align="center" style="color:#ffffff">ninjaturtle</td>
      </tr>
      <tr>
        <td bgcolor="sick"  cellpadding="8" width="100" align="center">sick</td>
        <td bgcolor="crap"  cellpadding="8" width="100" align="center">crap</td>
        <td bgcolor="grass" cellpadding="8" width="100" align="center">grass</td>
      </tr>
    </table>

    This also answers the other part of the question: Why does bgcolor="chucknorr" produce a yellow colour? Well, if we apply the rules, the string is:

    c00c00000 => c00 c00 000 => c0 c0 00 [RGB(192, 192, 0)]
    

    Which gives a light yellow gold colour. As the string starts off as 9 characters, we keep the second ‘C’ this time around, hence it ends up in the final colour value.

    I originally encountered this when someone pointed out that you could do color="crap" and, well, it comes out brown.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After certain R#-recommended edits R# colors the background of blocks of code in a
How do you generate a random number within a range while excluding certain range(s).
string str contains somewhere within it http://www.example.com/ followed by 2 digits and 7 random
I want to display a random record from the database for a certain amount
I am trying to generate a random number that only populates a certain percent
using jQuery, I'm trying to see if a random id ends with a certain
Can I ask for a certain code on how to generate a random letters
Possible Duplicate: MySQL: Select Random Entry, but Weight Towards Certain Entries I have a
Certain methods in Java will block until they can do something, like ServerSocket.accept() and
Certain list comprehensions don't work properly when I embed IPython 0.10 as per the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.