Allow the `<a>` tag to be recognized for internal doc links

So we know we can link to any of the headers inside a document. For example:

You have your header: # header to be linked

and depending on the app you use you can use [](#header-to-be-linked) or [](#header to be linked) to connect/jump to it.

I learned that the <a> tag could be used similarly, even for non-header linking:

<a name="link1"></a> can be used as a portal for [](#link1)

You can even wrap the a tag around text, so it expands one’s options on what can be referenced to:

<a name="link1"> some text </a>

I tried this and it works with Typora and Markdown Live Preview, but not on Obsidian and another markdown app I’ve used.

Is anyone aware of this?


For testing

  • Hop onto Markdown Live Preview
  • type in [link to last line](#head1234) and …
  • on the very last line, just wrap it with <a name="head1234"></a>. So it will just look like <a name="head1234">May the `Force` be with you</a>
1 Like

Just curious, what’s the advantage of this over the currently-functioning options you noted?

The current options link to headers only, but sometimes I just want to get to the point, which may just be a single sentence somewhere.

I think it can be very useful if able to incorporate into the [[]] tags.

Ah, so in particular you’re interested in the name attribute of anchor HTML elements.

Even more powerful are id-based links, as they can be used to link from one document to an arbitrary element in another document: https://www.w3.org/TR/html401/struct/links.html#h-12.2.3

(The scope of name attributes is the current document only, far as I understand it.)

So, yes, this is a nice idea, although it would make the text of notes pretty ugly if you were to use it a lot.

The name or id attributes didn’t necessarily concern me beyond the possibility of connecting to the selective text I was interested in. I was exposed to both attributes in the results I found, but neither worked on Obsidian, so I just picked the name attribute as an example, but it’s good to know it’d be more advantageous to use id-based links. :+1:

And yeah I figured notes could get ugly, especially if used too much, but I was hoping on some CSS customization in the meanwhile to at least help it stand out in editing, and an eventual WYSIWYG editor to make it easier to cover up (as in Typora).

1 Like