I understand that Stack Overflow answers are released under a Creative Commons license, and that I may use code from Stack Overflow answers (such as this one) in my work.

I want to give credit (as this question mentions that I should) to the OP, how exactly should I do this? I was thinking of adding something along these lines above the relevant code:

// Code created with the help of Stack Overflow question
// https://stackoverflow.com/questions/3808808/how-to-get-element-by-class-in-javascript
// Question by Taylor:
// https://stackoverflow.com/users/460058/taylor
// Answer by Andrew Dunn:
// https://stackoverflow.com/users/451672/andrew-dunn

That's right, right?

  • 2
    See also Attribution Required on the blog.
    – Arjan
    Mar 21, 2012 at 18:12
  • Thanks. Could you write that comment as an answer so I can close this question?
    – Adjam
    Mar 21, 2012 at 18:15
  • 2
    Well, does it really fully answer your question? Reading it myself, I could come up with many ways to interpret it...
    – Arjan
    Mar 21, 2012 at 18:16
  • 3
    This seems to me an excellent way to give attribution on your code
    – Lamak
    Mar 21, 2012 at 18:26
  • 1
    In lieu of other answers I will assume that my method of attribution is legit.
    – Adjam
    Mar 21, 2012 at 21:24
  • So it means, I have to give attribution to this question in my code if I'm planning to use this format? Apr 14, 2019 at 20:30

1 Answer 1


The Attribution Required blog post describes the attribution requirements in detail.

That said, if someone uses a small snippet of code that I post in a public forum for people to freely use, I don't particularly care that it be attributed back to me. In fact, some users feel strongly enough about this that they put a disclaimer in their profile.

I view the CC:Wiki license as more of a protection against leeches that wholesale copy material from Stack Overflow and create their own websites with it, without giving credit to Stack Overflow or the original authors of the material.

  • 1
    I just add links to the SO questions or answers in my comments in my code. Do I need to add a link to the author too? I figured the author is on the post if you opened the link to the post.
    – gen_Eric
    Mar 21, 2012 at 19:35
  • 1
    Links have a tendency to rot. I would imagine proper attribution includes not only a link, but "Stack Overflow" and the author's name. At least, that's what the blog post says.
    – user102937
    Mar 21, 2012 at 19:39
  • I usually just do // From http://stackoverflow.com/a/381754/206403 in my code. If the link to the question is gone, then a link to user wouldn't do too much.
    – gen_Eric
    Mar 21, 2012 at 19:40
  • 2
    (Hmmm, @Rocket, why linking using your own user id? ;-))
    – Arjan
    Mar 21, 2012 at 21:06
  • @Arjan: I'm aware of that, but I don't really care if my user id is there. What could happen? :-P
    – gen_Eric
    Mar 21, 2012 at 21:23

You must log in to answer this question.

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