HTML 에서 "chucknorris"는 왜 색깔로 취급되나요?

LONGNEW·2021년 1월 2일
0

StackOverFlaw

목록 보기
9/16

https://stackoverflow.com/questions/8318911/why-does-html-think-chucknorris-is-a-color

Q. Why does HTML think “chucknorris” is a color?
Q. 왜 'chucknorris'를 색깔로 취급하나요?
How come certain random strings produce colors when entered as background colors in HTML? For example:
HTML에서 그냥 랜덤한 문자열이 어떻게 색깔을 나타내는 거죠??

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

..produces a document with a red background across all browsers and platforms.
모든 창을 빨간색으로 바꿔버려요..
Interestingly, while chucknorri produces a red background as well, chucknorr produces a yellow background.
흥미로운건, chucknorri도 빨간 배경을, chucknorr는 노란 배경을 만들어요.
What’s going on here?
도대체 무슨일이 생기는거죠?>???><>?<<>?>?


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.
숫자로 나오지 않는 것들은 0 으로 취급합니다. 불확실한 숫자들도 0으로 해석 되죠. 예를 들어.
#F0F0F0, F0F0F0, F0F0F, #FxFxFx and FxFxFx 이것들은 모두 같게 취급 됩니다.

If we apply the rules, we get the following:
자 이 규칙을 적용해 보도록 하죠.
1. Replace all nonvalid hexadecimal characters with 0’s:
1. 16진법에 맞지 않는 것들을 0으로 교체 합시다.

chucknorris becomes c00c0000000
  1. Pad out to the next total number of characters divisible by 3 (11 → 12):
  2. 단어가 3으로 나눠 지는 길이로 늘립니다.
c00c 0000 0000
  1. Split into three equal groups, with each component representing the corresponding colour component of an RGB colour:
  2. 3 그룹으로 나누고 각각의 그룹은 RGB 컬러를 이루는 요소가 됩니다.
RGB (c00c, 0000, 0000)
  1. Truncate each of the arguments from the right down to two characters.
  2. 각 요소들은 2자리 밖에 필요하지 않으므로. 길이를 줄여 줍니다.(오른쪽 에서 부터)
    Which, finally, gives the following result:
    그렇게 해서 아래와 같은 결과를 얻죠.
RGB (c0, 00, 00) = #C00000 or RGB(192, 0, 0)

This also answers the other part of the question:
이것이 다른 질문들의 답이기도 하죠
Why does bgcolor="chucknorr" produce a yellow colour?
bgcolor="chucknorr"는 노란색을 배경에 칠하는 가?
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.
문자열이 9개의 캐릭터로 이루어져 있고. 두번째로 나오는 C를 가져가면서 노란색이 만들어 지네요.

https://z-p42.www.instagram.com/p/B_NKYuSgibo/c/17872971086024762/?hl=tr

0개의 댓글