-3

Usually in HTML you can use:

<a name="foo">

or

<div id="foo">

Then with something like:

<a href="http://example.com/page.html#foo">Jump to #foo on page.html</a>

You can link to a specific part of a page.

How can I do that in my questions on Stack Overflow? I checked:

https://stackoverflow.com/editing-help#links

But it did not give me an answer to that question.

I think it's a pretty useful option in some situations, so I would be a bit surprised if there is no option like that.

So how can I link to a specific part of my question on Stack Overflow (hashtag)?

2
  • 1
    SO only allows a very strict set of html tags and on some tags a limited number of attributes: meta.stackexchange.com/questions/1777/…. You can't achieve what you want as nor id nor name are allowed on any of the html tags. The last time I checked the CommonMark spec also didn't mention any standarized way to create or link to elements from an anchor so I doubt this will see an implementation in 6 to 8 weeks.
    – rene
    Commented Nov 21, 2017 at 13:42
  • @rene Thanks! Because of the other answers i already noticed that unfortunately it's not possible. Commented Nov 21, 2017 at 13:45

3 Answers 3

9

This would be sending the wrong message.

Questions should be as brief as possible. We don't generally want to encourage the kind of post length that would necessitate something like this. Lengthy questions rarely fare well.

20
  • Thats true.. Out of curiosity would the same logic apply to answers as well? Sometimes answers do get a bit lengthy as it gets updated over time..And the editor used is the same
    – Suraj Rao
    Commented Nov 21, 2017 at 13:07
  • @Suraj yeah there's a small number of valuable book-length answers where this might make sense... but generally, we don't want to encourage those either.
    – Pekka
    Commented Nov 21, 2017 at 13:09
  • I disagree. The question itself can be short, but Stackoverflow is always asking for: "Share your research.". So some questions can be the result of a lot of research. So in a case like that the question itself can be short, but the post on Stackoverflow can be long. Commented Nov 21, 2017 at 13:14
  • @Pekka웃 About "encourage those either" ... so actually Stackoverflow doesn't want more complex questions which requires more research? So i have to see Stackoverflow just as a platform for "simple" / short / easy questions? Commented Nov 21, 2017 at 13:18
  • @MaartenBruins how long are we talking? do you have such an example? Questions do need to contain research and (when needed) a minimal VCE. But they shouldnt be a blog post either
    – Suraj Rao
    Commented Nov 21, 2017 at 13:21
  • @SurajRao What do you mean by "how long are we talking"? And what do you mean by VCE? English is not my first language. I checked this: en.wikipedia.org/wiki/VCE but i don't know exactly what you mean by that? Commented Nov 21, 2017 at 13:28
  • @MaartenBruins ah sorry.. I meant MCVE. And I want get an idea of what length question would need subsections. And English isnt my first language either :-p
    – Suraj Rao
    Commented Nov 21, 2017 at 13:29
  • @SurajRao An example is this one: stackoverflow.com/questions/47412949/… I agree with you that it's not 100% a question, so maybe i must not use Stackoverflow for it, but which platform i can use for things that are in between a question and a post? My example are more about definitions, which i think are wrong, so i post it on Stackoverflow to see if more people are agree with me (or maybe disagree), before i'm doing other things with that information. Commented Nov 21, 2017 at 13:33
  • 2
    @MaartenBruins so actually Stackoverflow doesn't want more complex questions which requires more research? oh, we do want those. We just don't want them to be super long because people tend not to read super long stuff. Brevity is an art form.
    – Pekka
    Commented Nov 21, 2017 at 13:34
  • @MaartenBruins Just think of it like this, if a question is too long than it is usually to broad too. Stack Overflow is place for exact and specific problems which can benefit the OP and others who may come looking for the same solutions. If the question is too long than it means it is the solution will e tailored for the OP, and new viewers on that question might not be able to benefit from those solutions.
    – mega6382
    Commented Nov 21, 2017 at 13:38
  • @mega6382 and Pekka: I agree with you about that. But giving the option (in case you need it), does not mean you have to use it all the time. Actually i don't really think people will make suddenly longer posts / questions, because suddenly there is an hashtag / link option. If they post a long question, it would be anyway the case i think (and not because of being able to link to specific parts). Commented Nov 21, 2017 at 13:52
  • 2
    But anyway thanks for the answer. At least now i know it's not possible and i just have to accept it, because apparently there are no plans to change it. Commented Nov 21, 2017 at 13:54
  • 1
    @Maarten I don't speak for SO, but I'd be surprised if this were on their list. But giving the option (in case you need it), does not mean you have to use it all the time. that is totally true, but our experience here is that user behaviour is influenced by the features that are on offer. Offering such a feature would almost certainly be interpreted as encouragement to produce lengthy content where we actually want the opposite: to put things as briefly as possible. That doesn't mean there aren't individual cases where it would be useful, but on a site like SO you have to think big scale
    – Pekka
    Commented Nov 21, 2017 at 14:02
  • 2
    @MaartenBruins the post you've linked is not structured like a question. It indeed shows research, but trying to figure out what (if anything) you are asking is hard. "I will use this post to report it to Mozilla, so it's actually not 100% a question" part does not make it any better as a question... (I'd vote it as "unclear" or "too broad" if I see it while looking through questions) Commented Nov 21, 2017 at 16:56
  • 1
    @MaartenBruins indeed no one going to stop you to post off-topic content on SO . Please make sure you understand that such posts will likely get decent number of downvotes/closed and you'll have trouble posting on SO if you continue posting such content. Reading meta posts about guidance where to post off-topic content may be useful... (i.e. meta.stackoverflow.com/questions/252777/…) Commented Nov 21, 2017 at 17:55
3

You can not divide your questions into parts. And I don't think there would be any use to it. Also, SO posts do not accept most of the HTML attributes and tags.

There is a lot of potential for abuse with this. for example, if people started using the ids of the elements that the site uses for its own HTML elements, etc.

And Questions usually shouldn't be too long that they need linking to subsections of it.

3
  • I disagree. The question itself can be short, but Stackoverflow is always asking for: "Share your research.". So some questions can be the result of a lot of research. So in a case like that the question itself can be short, but the post on Stackoverflow can be long. And about the abuse: You can also use "id=" or "name=". And Stackoverflow could use a special prefix for that, so then your argument is not valid anymore. Maybe you have another / better example? Commented Nov 21, 2017 at 13:14
  • @MaartenBruins how many posts with super long "research" sections have you seen on Stack Overflow, though? Can you point even to one where direct linking is essential? I put it to you they are very rare (plus research typically tends to be linked inline in the text). And even if there are some, you can easily "link" to it by saying "check out the 'research' section in this answer"
    – Pekka
    Commented Nov 21, 2017 at 13:33
  • @Pekka웃 I just gave an example in the other answer. So you can see my reply there. Commented Nov 21, 2017 at 13:39
-7

Click "share", and you'll get a link to the answer:

enter image description here

4
  • Did I misunderstand the question?
    – Maroun
    Commented Nov 21, 2017 at 12:58
  • 1
    I think OP meant linking within the post like creating subsections and linking to it. Though OP doesnt seem to be quite clear
    – Suraj Rao
    Commented Nov 21, 2017 at 13:00
  • Yes, it's about linking to a SPECIFIC part of the question and not linking to the question itself. Commented Nov 21, 2017 at 13:01
  • 8
    @SurajRao Ah, so I did misunderstood the question. But at least I have a free-hand red circles.
    – Maroun
    Commented Nov 21, 2017 at 13:01

Not the answer you're looking for? Browse other questions tagged .