2

Sometimes I use links inside code blocks, e.g.

interface HTMLCollection {
  readonly attribute unsigned long length;
  getter Element? item(unsigned long index);
  getter Element? namedItem(DOMString name);
};

Here in meta links are underlined so it's easy to see them, but in main site it looks like this

enter image description here

You can only discover the links if you hover them and notice the pointer cursor.

So I propose underlining links inside code blocks. Something like

code a {
  text-decoration: underline dotted;
}

This will also affect inline code, which does not really need it because links have color: #07C, but might be good for coherence. Otherwise restrict the selector to pre > code a.

7
  • 3
    Links don't belong in code -- it's a distraction, and makes it harder to read the code. If you want to link to docs, you can do it outside the code block :)
    – user4151918
    Apr 23, 2016 at 16:14
  • @PetahChristian Note I only include links when I quote a specification, the specification has links, and the formatting of the spec is important. The example above is Web IDL code used by the DOM spec to define an interface, it's not supposed to be run by any program.
    – Oriol
    Apr 23, 2016 at 16:18
  • 2
    I have never ever had a situation where the links in a WebIDL definition in a Stack Overflow answer were important enough in context that I absolutely had to include them like that.
    – BoltClock
    Apr 23, 2016 at 16:21
  • 1
    Whether this feature gets implemented depends entirely on whether the <pre><code> method of marking up code blocks is supported in the first place. Note that "works" != "is supported".
    – BoltClock
    Apr 23, 2016 at 16:22
  • @BoltClock They are not vital, but I think they are nice.
    – Oriol
    Apr 23, 2016 at 16:22
  • @Oriol In your answer, you already linked to HTMLCollection, which itself already had links for the definition. You've merely duplicated what the spec already provided. The additional links (in the code) may save the user one click, but introduce more possibilities of link-rot.
    – user4151918
    Apr 23, 2016 at 16:30
  • @PetahChristian That's a good point. But I still think links in code blocks are not visible enough. In a certain point of view, this could even be considered a bug: syntax highlighter wraps text inside links in a span of some color, preventing the default color: #07C of links from being applied.
    – Oriol
    Apr 23, 2016 at 16:55

0

You must log in to answer this question.