I want to get rich snippets in Google for Q&A like StackOverflow. How do I do this? What structured data do I need?
Here is the screenshot:
Webmasters Stack Exchange is a question and answer site for pro webmasters. It only takes a minute to sign up.Sign up to join this community
In particular and at minimum, use the following attributes/properties:
itemscope itemtype="http://schema.org/Question"on the DOM element wrapping entire set of question & answer content
itemprop="name"(typically on an H1) wrapping the individual question
itemprop="acceptedAnswer" itemscope itemtype="http://schema.org/Answer"on the DOM element wrapping the accepted answer
itemprop="suggestedAnswer" itemscope itemtype="http://schema.org/Answer"on the DOM element wrapping other answers
You may also (optionally) want to consider attributing questions and answers to individual people/users, using the Person scheme.
Below are screenshots of one of the examples from schema.org for quick reference.