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: &

  • Saganaki@lemmy.one
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    1 year ago

    The reason is because a programmer at some point decide that & should indicate the start of a special symbol in HTML. In programming parlance this is a means of “escaping” characters which are reserved.

    For example, in HTML, things look something like this:

    <p>Hello, World!</p>
    

    The p in the less than and greater symbol symbols means “paragraph” where the ending version with the slash means “the paragraph is done”.

    However, there’s a problem. What if you wanted to actually type out <p> to the end-user and have it not be treated as HTML? You use the ampersand syntax to write &lt; by using &lt; and > by using >.

    </p><p>&lt;p></p>
    

    Yet another problem: If we use &amp; as a special character in HTML, we also need a way to display it—the answer is &amp;