Growing with the Web

Giving better answers on Stack Overflow


Putting yourself out there and answering questions on Stack Overflow is a great way to grow as a software developer. Not only does it let you practice more at what you’re good at, it also let’s you dip your toes into areas where you’re less familiar or learning. There is a lot to providing great answers on Stack Overflow, here are some tips to help out.

Stack Overflow logo

Formatting matters

A little bit of formatting goes a long way on Stack Overflow, usually there are two or more answers that are essentially the same. Anything you can do to make your answer better will make it shine through above the rest. Learn a little Markdown and you can make answers far nicer to read with very little effort. Add a heading, wrap your code in a backtick (`) to format the code, and always make sure you indent correctly.

Here is the syntax to some common Markdown formatting and tags that make your answer shine:

  • `code` → code
  • *italic* → italic
  • **bold** → bold
  • ***bold italic*** → bold italic
  • # heading 1<h1>heading 1</h1>
  • ## heading 2<h2>heading 2</h2>
  • ### heading 3<h3>heading 3</h3>
  • - list item<li>list item</li>
  • <kbd>Ctrl</kbd> → A styled Ctrl key, use this to format keystrokes within answers semantically and visually

Adding references is a great way to improve your answer. It’s easy to add links to answers, just select the text you want to linkify and press Ctrl+K. Try to prefer links that are likely to stand the test of time such as official API documentation, wikis like MDN or within Stack Exchange.

Link only answers are discouraged on Stack Overflow and will likely be flagged and deleted. If you find an article that perfectly answers the question, try to extract the most relevant details and then link to the original source as a reference.

Provide a demo or add an image

For web related answers you should add a demo from jsfiddle or Stack Overflow’s relatively new code snippet feature if possible. Having actual working code just a click away is a surefire way to get upvotes and have the answer accepted.

Also consider adding an image if it’s useful. It’s easy to add an image to an answer, just hit Ctrl+G to bring up the insert image dialog. The image from the clipboard can then be pasted with Ctrl+V. And don’t forget to give the image some alt text when required so it can be understood by assistive technology.

Overkill your answer

One of the best ways to boost reputation and truly provide value is to overkill a question with more detail that the asker was expecting. Remember that you’re not just answering the question for the person asking, but for any random programmer experiencing a similar problem that happens to find their way to the question.

I started answering a lot of questions around the start of 2013, during that time I applied this strategy and some of those answers like these are my most up voted:

Race to the first answer

Unfortunately for the smaller, easier questions, it often feels like a race to get the first answer out so that you can get the first up votes to prevent your answer from being buried under the rest. For these types of questions, I typically answer with the bare minimum that constitutes a correct answer and then go back to add formatting, references, live demos and expand the explanation.

Don’t create an answer that is a comment

General comments on the question should not be submitted as answers. Answers should answer the question that is being asked. If it does not, it will likely get flagged and deleted.

Respond to comments

Stack Overflow will send you an email shortly after someone has commented on an answer you made, following up on these comments is a great way to help more people out. Some comments provide valuable insights that can even be incorporated into the answer itself.

Continually improve

Happen to stumble upon an old answer that isn’t up to scratch? Just hit edit and fix it up, future viewers will be grateful.

Like this article?
Subscribe for more!