this post was submitted on 12 Aug 2023
88 points (97.8% liked)

Explain Like I'm Five

14308 readers
395 users here now

Simplifying Complexity, One Answer at a Time!

Rules

  1. Be respectful and inclusive.
  2. No harassment, hate speech, or trolling.
  3. Engage in constructive discussions.
  4. Share relevant content.
  5. Follow guidelines and moderators' instructions.
  6. Use appropriate language and tone.
  7. Report violations.
  8. Foster a continuous learning environment.

founded 1 year ago
MODERATORS
 

I feel like whenever I see the ampersand on this website, it’s followed with “amp;”. I’ve noticed it other places on the internet also. Why does this happen? Is it some programming thing?

Just for a test: &

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 13 points 1 year ago* (last edited 1 year ago) (1 children)

There's not enough symbols on my keyboard and I want to type ¢ © ÷, so let's invent a system so we can write them and other symbols!

  1. lets say & means start of code
  2. and say ; means end of code
  3. Between the start and end is the code

Now let's make some codes

  • ¢ can be ¢
  • © can be ©
  • ÷ can be ÷

I want to tell other people how to use our new code, but if I tell them to "just write ÷" it'll turn my message into "just write ÷" !! So how can we fix this?

What if we make & its own code?

  • & —> &
  • ÷ —> ÷ ???

Yes! That'll work :)

This is how & came to be, and it's specifically used in HTML as a way to write those symbols above (and escape other a few other symbols for similar reasons we did with &)

As for why & shows up as &, there are 2 main places I can see this happening:

  1. The editor you use to write it automatically converts an & —> &. But the user typed in & (making it &). I think this is most likely. I'm guessing the title of posts automatically do the conversion, but the post body and comments do not because it uses a raw markdown editor
  2. In some contexts the & specifically doesn't get converted? like how you can write `&` to get & as opposed to seeing
[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

Lol, ok there might be a little more than what meets the eye, cuz when i type `&` (without amp;) it converted it to & !!

new challenge- try to get it to render a & instead of & inside of `` (or ``` ``` for bulk testing)

tried:

  • `&`
  • `&`
  • `&`
  • `&;`
  • `&<invisible character>`
  • `&divide;` still becomes `÷` weirdly enough

I kinda cheated cuz its not the same character... but I got it to show by using the japanese monospaced & (&)

test: