I've been looking around SO and Google for a way to link to certain parts of an SO question or answer. For instance adding to the top of your question/answer links to header tags that are further down the page, via the id or name attributes. For instance here is an example of linking to one answer to a Super User question via the name attribute of the a tag and the id attribute of the div tag.

This is a name tag and div tag found in the source of one of the questions 
asked on Super User.

<a name="337941"></a>
<div id="answer-337941" class="answer" data-answerid="337941"></div>

This links to an answer to the question asked on Super User by use of the name attribute.
<a href="https://superuser.com/questions/337853/britannica-on-linux#337941">Link</a>

This links to the same answer by use of the id attribute.
<a href="https://superuser.com/questions/337853/britannica-on-linux#answer-337941">Link</a>

Here is the link to the question asked above - Britannica on Linux?
Here is the link to the answer mentioned above - Answer

[SO] only supports a very strict subset of HTML! and the only tags which are allowed attributes are the <img> and <a> tags and neither one allows name="" or id="", and <a>'s title attribute is a global attribute in HTML5 that just shows a description when hovered over.

Basically I'm seeing if there is a way to do the following:

Assume this is my answer to a question on SO, and the link to the question is http://stackoverflow.com/questions/123/this-is-a-question.

This is my answer.
It is very long and contains different sections split up by <h2> tags, but if you don't
want to have to scroll through the whole question then just use a link provided below.

    <a href="http://stackoverflow.com/questions/123/this-is-a-question#S1">Section 1</a>
    <a href="http://stackoverflow.com/questions/123/this-is-a-question#S2">Section 2</a>
    <a href="http://stackoverflow.com/questions/123/this-is-a-question#S4">Section 8</a>

<h2 id="S1">Section 1</h2>
... section 1 blah
<h2 id="S2">Section 2</h2>
... blah
... blah blah blah
<h2 id="S8">Section 8</h2>

I'm sorry if this has been asked before, I searched Google and SO thoroughly, but maybe I didn't search for the right thing.

  • 1
    I would question whether allowing this will interfere with the structure of the pages as StackExchange already uses named anchors to allow navigation to answers on the page. – slugster Apr 30 '14 at 9:09
  • 1
    I was thinking that too, for example someone could add a name attribute like 123 or an id like answer-123 where 123 or answer-123 would link to that person's <h2> tag or any other tag allowing id or name attributes, which would navigate to that tag instead of navigating to the intended answer's anchor. But I still think there should be a more efficient way to find what your looking for in a question/answer rather than just scrolling through the answer/question until you find the section you were looking for. – Jonny Henly Apr 30 '14 at 9:50

You must log in to answer this question.

Browse other questions tagged .