69

From MDN, <samp>

The HTML <samp> element is an element intended to identify sample output from a computer program. It is usually displayed in the browser's default monotype font (such as Lucida Console).

This is of course very useful on all the "code" sites, but particularly also in documentation. Can we have a decent CSS style for it?

Usage example:

The following should appear on your screen:

<samp>sklivvz@DESKTOP-FP94G5S:~$ uname -r
3.4.0+</samp>

Expected output should look like a terminal or at least be <pre>:

The sample should appear on your screen:

enter image description here

Actual output does not even conform to expected HTML5 behavior:

The following should appear on your screen:

sklivvz@DESKTOP-FP94G5S:~$ uname -r 3.4.0+

17
  • 11
    Even better would be some sort of modifier for Markdown's blockquote syntax (akin to the prettify hints for code blocks), as that'd provide a fallback here (rendering it as <samp> would still be nice). I vaguely recall discussing something like this a couple years back, primarily for logcat listings.
    – Shog9
    May 18, 2017 at 23:10
  • Presumably he could have made a business case for this, but making it happen would still, presumably, require the same people to sign off on allowing it to happen? The only difference, I imagine, in asking now is that the request is more public. Though I can't imagine that's going to make a difference, really. May 18, 2017 at 23:11
  • @HansPassant I'm sure more users are just as disappointed as you seem to be but this request can have some merit in area's where SO Inc. is still invested in, like Docs. Not sure why you need to lash out like that to former devs as I doubt individuals can or should be held responsible for the direction a company moves to.
    – rene
    May 19, 2017 at 5:15
  • 4
    @HansPassant working there or not, one goes through meta for these feature requests. As for "you could have done it"... I doubt it. I know SO hasn't been developing the core codebase much in the last few years, in fact that's not unrelated to why I'm a former developer.
    – Sklivvz
    May 19, 2017 at 5:59
  • 4
    @Shog9 sure but that's a complex request and the markdown should still render to <samp>. One step at a time. Let's see if we can get 2 hours of a designer to implement a style on a minor HTML5 tag first.
    – Sklivvz
    May 19, 2017 at 6:01
  • 4
    Oh yes please! And if it happens, could we have it on other sites on the network? I can see this being handy on the rest of the trilogy, U&L, AU.... May 19, 2017 at 6:45
  • 4
    I'm being pedantic, but when you say "Expected output should look like a terminal or at least be <pre>", why would you expect that? The default browser style for <samp> is only the monospace font, nothing else.
    – Mr Lister
    May 19, 2017 at 11:06
  • 2
    @MrLister why would the default browser style be the expected behavior of this feature request?
    – Sklivvz
    May 19, 2017 at 11:26
  • 5
    What is the advantage of such a tag over a regular code block? May 19, 2017 at 11:31
  • 2
    @Sklivvz Otherwise it wouldn't be expected, now would it.
    – Mr Lister
    May 19, 2017 at 11:36
  • 6
    @Carpetsmoker The number of times I've typed <!-- language: lang-none --> has to be into the hundreds at this point....
    – user1228
    May 19, 2017 at 17:04
  • I've read it as "please add the support for the <spam> tag" :D
    – nicael
    May 21, 2017 at 15:54
  • Actual output does not even conform to expected HTML5 behavior Not strictly true as the output is simply rendered as <p> tags instead of <samp>. However, I would really like to see this feature for console output, logs, probably even error messages.
    – DavidG
    May 21, 2017 at 17:37
  • when to use samp tag and when use output tag ? May 21, 2017 at 19:12
  • @WalleCyril well you can't use either yet. But imagine samp would render something like this codepen.io/anon/pen/rmQqPX
    – DavidG
    May 21, 2017 at 19:40

0

You must log in to answer this question.

Browse other questions tagged .