Link

Share

On the internet, a "link" is a clickable text, typically stylized blue, that when clicked makes a web browser display a different web page on a different URL.

A Wikipedia showing text with blue links.
On Wikipedia, every text in blue is a link to a different article.

How do you create a link?

Links are a fundamental part of the world wide web. Technically, they are called "hyperlinks," and the text of the web pages "hypertext." This hypertext is described in a code called HTML, or HyperText Markup Language.

In HTML, a hyperlink is described with an "anchor"(w3) tag, abbreviated as the letter A. This tag has a href attribute for "hypertext reference"(w3) whose value is a URL to the linked webpage or other resource like an image or file to download.

For example, a HTML code like this:

<a href="http://example.com">Visit example.com</a>

Becomes this:

Visit example.com

If you can write raw HTML then a code like the above will make a link. However, this only happens if you're creating your own website or your own blog. If you're writing a post in someone else's website, that website probably won't let you just type raw HTML code, because, if you could, you would be able to do the same things as the website owner, which means you'd be able to display images and videos and run scripts at everyone who accesses a web page with your post. This is a huge security risk, so websites don't let users do that. Besides, each user would also be able to write invalid HTML which could mess up with the whole web page. You really don't want that.

Instead, when a website lets users post, it may allow some other sort of code that is less powerful than the full, raw HTML. This filtered sort of code will let you do basic formatting like make text italic or bold, and make hyperlinks, but it won't let you do anything more complicated, even, for example, making the text centered, making it bigger, or making the text a different color. The capabilities of this "post" code varies from site to site, but the idea is that the site takes what you write, interprets it as some sort of code, and then translates that code into HTML code so a web browser can understand it.

Links in BBCode

For example, in BBCode, which is used in some forums, to make a link you would type something like:(phpbb)

[url=https://www.phpbb.com/]Visit phpBB![/url]

Web browsers can not understand BBCode, only HTML code, so this is useless for them. So what happens is that when you type something like the above in your post, the website would take it and translate it to the equivalent HTML, with <a> instead of [url], so it's a code web browsers can understand and then they will make the links work appropriately.

BBCode is used in some forum websites.

Links in Markdown

Another type of popular code language for writing posts is called Markdown. It works the same way as BBCode. If you're visiting a website that lets you write posts in Markdown, then you type Markdown code, the website converts it to HTML, and everyone sees your posts as HTML. With Markdown, links look like this:(daringfireball)

This is [an example link](http://example.com).

Markdown can be used in Reddit.

Links in Social Media

Many modern social media, like Facebook and Twitter, were designed with the idea that the user should have minimal control over how the posts look like. Because if you let someone make text bold, you'll have people who make all the text bold all the time. If you let them change the text color, some people will use illegible colors all the time. If you let them make text bigger or smaller, same problem. So they figured it was easier to not give users the ability to format text at all. No ability to format text meant there was no code, and no code means there's no way to explicitly declare a link, but that's good, because in their view, the user can't be trusted and there's too much potential for abuse.

For example, code that lets you declare links often let you type one phrase that becomes clickable, like "click here to visit an awesome site," and then the URL, like example.com, is written only in the code so that when the HTML page is rendered other users don't see the URL you typed anywhere on the page, they won't know the link goes to example.com until they click the link (or hover over it). But this also means the user could write "click here for ponies" and the URL points to a very disturbing website that doesn't even have any ponies in it.

So what was the solution to this?

In such social media websites, posts have a "code" format, but this is format has very, very few features, so it doesn't even look like code.

For example, to create a link, you normally just type the URL.

If you type https://example.com in a post, then the website will see that you typed a very long thing without any spaces in it that starts with https and it will assume the whole thing is a URL and convert that to a hyperlink in HTML. This also means that if you just type example.com, that may or may not work depending on whether the website is smart enough to figure out that's a website just because it ends with .com.

On the other hand, nowadays we have a lot of TLDs beyond .com, including some truly awful ones like .zip, which is also the file extension of zip archives. It's possible that some website out there will see someone write "just check the photos.zip file" in a post or e-mail and convert that photos.zip filename into a link, thinking it's a domain name, and it's also possible a hacker owns that domain and is just waiting for a mistake like this to happen and for some poor fellow to click on that link.

Other problems can occur with this link auto-detection, too.

While knowing the start of a link copy-pasted is fairly easy since it always starts with http:// or https://, knowing where it ends isn't so easy. You see, a URL can contain a question mark (?), can contain a period (.), and it can even contain a comma (,). If I type "check https://example.com, it's a neat site" does the "," after ".com" get interpreted as part of the URL or not? Normally it will not. To be safe, it's a good idea to put a space yourself after the URL:

Check https://example.com , it's a neat site.

Most websites don't have trouble with this, but Wikipedia is one site that often has commas and parentheses in its URLs, so its links have misinterpreted URLs a lot.

Besides social media websites, chatting and messaging programs like Discord also employ this automatic conversion of URLs to links. More than that, they may even show a preview of what the page is supposed to be, its title and description, to further avoid having users click on links that go to websites they wouldn't want to click on.

An unusual case is that Reddit lets you link to a subreddit by typing just /r/subredditname. When an anchor href starts with /, the URL becomes relative to the current website, so /r/funny on www.reddit.com equals https://www.reddit.com/r/funny. But URL-to-link converters normally don't bother with URLs that start with /. In fact, neither does Reddit. It just treats words that start with /r/ as if they were subreddit URLs.

Hashtags

In some websites that support hashtags, like Twitter, Instagram, Facebook, etc., typing an octothorpe (#) before a word turns it into a link to that "hashtag." This may or may not "tag" that post with that hashtag so it can be found it you search for that hashtag on the website.

Because it's code, it has to be interpreted, the hashtags can't contain spaces. The website uses an octothorpe to know where the hashtag starts, and a space to know where it ends, so they can't have spaces. You can't have a "new year" hashtag, it has to be #newyear.

In sites that have a special place for you to input a post's tags instead of just trying to guess them from the text in your post, it's perfectly possible to have tags with spaces. Tumblr, for example, allows this.

Mentions

In some websites, it's possible to link to an user by typing @their_username. In this case they may get a notification. On Reddit, /u/username works similarly.

Timestamps

On Youtube, it's possible to link to a timestamp by just typing the timestamp. For example, 01:40 links to the first minute, 40th second of the video.

References

A Beginner's Guide to HTML, https://www.w3.org/MarkUp/html-test/ncsa/HTMLPrimer.html, accessed 2023-09-03.

BBCode guide, https://www.phpbb.com/community/help/bbcode, accessed 2023-09-04.

Markdown: Syntax, https://daringfireball.net/projects/markdown/syntax, accessed 2023-09-04.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *