While redoing Where and how to start learning Perl I had some difficulty finding out to link to a named anchor in another node on the Perl Monks site, for instance to Regular Expressions in Tutorials.

I’ve got it now and I wonder if this link works in every browser. I’ve tried Mozilla 1.5a and IE 6.0 and it seems to work fine.

I realize that in the majority of cases, such links are not necessary or disturbing. But sometimes it is just nice to use a named anchor anyway.

Link to a named anchor in the same node
In a long node it might aid the reader to make chapters, or just refer to some specific part in the node.
With links like these: Anchors like these can be included in the section where the link should point to:
<a href=#anchorname>Text Text Text</a>
<a href="#anchorname">Text Text Text</a>
<a name=anchorname>Text text text</a>
<a name="anchorname">Text text text</a>

Link to a named anchor in another node
A lot of ways to link to a named anchor in another node do not work correctly, the link will be translated into a faulty URL. Some examples that do not work:
[nodename#anchorname|Text text text]
 [id://954#anchorname|Text text text]
<a href="nodename#anchorname">Text text text</a>
<a href=nodename#anchorname>Text text text</a>

The solution of a link with a named anchor seems not to be possible with square brackets […]. The only way seems to be to use the “real HTML” <a href=…> with the full path from the root. These examples work fine:
<a href="/index.pl?node=954#regexdata">Regular Expressions</a>
<a href=/index.pl?node=954#regexdata>Regular Expressions</a>

Are there easier and/or more elegant ways to do this? Am I missing something?


In reply to Named anchors in current node or in another node by woolfy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.