Is it advisable to use the code-block for inline-code like DataGridView or WinForms.Webbrowser?

eg: Windows Forms Webbrowser Full history

Some Mods also do it: Null Pointer exception in C#

And should I highlight the second appearance too?

E.g at Wikipedia you only highlight the first appearance.

  • would be nice if the downvoter leaves a comment with a reason. – Vloxxity Nov 16 '12 at 16:46
  • 10
    It would be nice if people read the FAQ before posting on any site (including Meta). – yannis Nov 16 '12 at 16:53
  • 6
    Welcome to Meta! What Yannis was trying to point out is that voting works differently on meta sites. It often indicates disagreement, rather than "your question makes no sense." I can't speak for everyone, but I downvoted you because I agree with Michael and ThiefMaster (i.e. think it's not advisable to use code formatting for "highlighting"). – Pops Nov 16 '12 at 17:12
  • 3
    Please don't use backticks to "highlight" random words. See: meta.stackexchange.com/questions/137755/… – NullUserException อ_อ Nov 16 '12 at 17:51
  • 1
    If you're introducing a technical term, it might be appropriate to highlight it by using italics (surround it with * characters). – Keith Thompson Nov 16 '12 at 18:07
  • 2
    but WinForms.Webbrowser and DataGridView in this case is a piece of code... so i could highlight it !? – Vloxxity Nov 18 '12 at 22:12
  • @PopularDemand You can disagree with a Statement, but how do you disagree with a question? I asked it because im not sure, and i din´t say someone should do it. – Vloxxity Nov 21 '12 at 13:56
  • 3
    @Vloxxity it's bit more complicated than "disagree with a question". It's more like "disagree with the idea behind the question", in this case you are suggesting that certain words need to be backticked in posts and right now 7 users agree with this idea while 9 disagree. Hope this makes more sense now? – Shadow Wizard Wearing Mask Nov 21 '12 at 14:45
  • @Vloxxity Sha Wiz Dow Ard summed up what I meant. Your post asks "is it advisable to do X" and "should I do Y." In this case, upvotes might indicate yes (i.e. it is, and you should) and downvotes would indicate the opposite. – Pops Nov 21 '12 at 14:59
  • 1
    @PopularDemand yeah i think your right... but those downvotes feel like a punch in my face: are you dumb or why are you asking that, imo they should rather upvote the answer that says no you shouldn´t – Vloxxity Nov 21 '12 at 15:23
  • 2
    @Vloxxity I see where you're coming from, but it's just something you have to get used to. It's like learning a new language. "Blesser" is a word in English. It's also a word in French. But even though they look the same, the French one and the English one have totally different meanings. So, please don't take the downvotes the wrong way, because even though they look like the painful downvotes you're used to, they don't mean the same thing. – Pops Nov 21 '12 at 15:23

That's not a highlight; that's a code block. And no, it's not appropriate to use it to highlight technical terms. it should only be used on blocks of code:

public bool IsActive
    get { return _isActive; }
    set { _isActive = value; }

or inline code: _log.Debug("Setting hyperspace mode");

You can occasionally get away with using it to call out things like class or object names ("Why must I initialize a Dictionary this way?"), and angle brackets hide unless you use <code blocks> to show them, but try to limit that. It gets annoying awful fast, to see code formatting littered throughout your text.

| improve this answer | |
  • 2
    You have to code-format angle brackets if you want them to be visible... – AakashM Nov 16 '12 at 16:53
  • also note that it causes the text between the ticks to be treated as literal text, not HTML or markup. Dictionary<string, string> doesn't display right in an answer if it's not wrapped in backticks. – Servy Nov 16 '12 at 16:53
  • 5
    It is also helpful to use backticks to differentiate keywords in code from words in your sentence. If you have an in in your code, you are suggesting that someone use for for their loop or using using instead of Dispose then it's much harder to understand without any backticks. – Servy Nov 16 '12 at 16:55
  • You're right about the angle brackets; incorporated. – Michael Petrotta Nov 16 '12 at 16:58
  • 1
    Oh really: Dictionary<string, string> – Eric Nov 19 '12 at 8:28
  • 1
    @Eric in an answer. You can even see this in the preview window: start an edit of this very answer and remove the backticks around <code blocks>; note that the words disappear in the preview pane. – AakashM Nov 19 '12 at 8:51
  • 2
    @AakashM using the HTML &lt; and &gt; you can get your precious angle brackets to appear in an answer, but it doesn't work in comments. – Richard J. Ross III Nov 21 '12 at 13:52
  • @RichardJ.RossIII ... or you could just use backticks, which work in posts and comments – AakashM Nov 21 '12 at 14:07

No, you should not "highlight" any of them. The backtick operator is meant for code highlighting and those words are not code. However, if something in your text is actually code or code-like (a filename might qualify for example) using this formatting is fine.

On a side-note: Edits adding such formatting should be rolled back (or rejected if just suggested) with extreme prejudice. Slapping trouts into the face of the editor would also be a good idea.

| improve this answer | |
  • 1
    Sometimes adding code formatting can dramatically improve the readability of a post, when distinguishing English-y keywords like for or is, or when a non-fixed-width font makes an expression too dense with narrow characters like parentheses. – McCannot Nov 16 '12 at 17:26
  • for etc in such a context would be code. And thus highlighting those words would be perfectly fine. – ThiefMaster Nov 16 '12 at 17:58
  • 1
    Ah, I misunderstood, sorry. Actually, I'd say not everything that could be considered code really needs highlighting, and edits that do nothing but put backticks around a bunch of perfectly readable class or method names annoy me (that they often ignore other formatting issues doesn't help either). – McCannot Nov 16 '12 at 18:06
  • just updated the question see edit... – Vloxxity Nov 18 '12 at 22:20


I have DataGridView in my form, my variable is myGridView. myGridView is being set in Page_Load and the DataGridView is loading from a data source which reads from database.


I have DataGridView in my form, my variable is called myGridView. This variable is being set in Page_Load and the DataGridView is loading from a data source which reads from database.

My $0.03:

  1. When the term sticks out already, no need to backtick it. DataGridView got three capital letters and will stick out in any context so can't see reason to wrap with as inline code, unless of course it is part of a longer code. You can use DataGridView to make it more noticeable.
  2. In case of variable names this is more reasonable to mark it as inline code, but try to not use the name too many times.
  3. All in all, there isn't one rule for this; each case is specific and depends on the context.
| improve this answer | |
  • 2
    You must hate my answers sometimes, then. I would have code-blocked everything in your first sample except data source and database. – Frédéric Hamidi Nov 21 '12 at 13:52
  • @Frédéric not hate; just think it's incorrect, reject suggested edits of that kind and on extreme cases rollback such edits, though I did it only once or twice. – Shadow Wizard Wearing Mask Nov 21 '12 at 13:57
  • Sure, we agree about those edits, but I was under the impression this question also addressed use of code blocks in original content. Now I'm wondering how I would react if someone edits one of my answers to remove some of the code blocks because meta says they're not appropriate ;) – Frédéric Hamidi Nov 21 '12 at 14:00
  • @FrédéricHamidi yeah i would also highlight the first appeareance of 'myGridView' and 'Page_Load' because those are names of functions or code objects. – Vloxxity Nov 21 '12 at 14:01
  • 1
    @Vloxxity, I would actually code-block all instances, not only the first ones. IMHO the "Wikipedia pattern" makes sense for hyperlinks but not for other content. (On the other hand, I do not code-block hyperlinks because I think the result is quite hard to read, especially on visited links. It's complicated.) – Frédéric Hamidi Nov 21 '12 at 14:05
  • i havent codeblocked the hyperlinks thats a quote-block. – Vloxxity Nov 21 '12 at 14:08
  • @Vloxxity, oh, I wasn't referring to that :) I was just saying I either write, say, $.ajax() or $.ajax() but not $.ajax() (harder to read on SO). – Frédéric Hamidi Nov 21 '12 at 14:10
  • ah okay didnt get that, also some mods like to do that see: meta.stackexchange.com/questions/100128/… – Vloxxity Nov 21 '12 at 14:13
  • @Vloxxity mods are no gods; when it comes to those things their opinion doesn't really have more weight than yours, Frédéric's or my own. – Shadow Wizard Wearing Mask Nov 21 '12 at 14:43

I'd argue that the semantic way of highlighting these terms are via the <i></i> tags in HTML5, but since StackOverflow's markdown doesn't support them you can do one of the following:

  • Do it yourself, Like so
  • Do nothing.
| improve this answer | |

You must log in to answer this question.

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