I've posted a question or an answer, and I have received one or more down votes. I am not really sure why I was down voted, or I think I know why, but I disagree.
Why did this happen, and what should I do about it?
A down vote is an opportunity to consider that perhaps your post could be improved somehow. If you are at all bothered by a down vote, I encourage you to consider the following.
First, you should never take a down vote personally. Remember that a down vote only takes away 2 points of your reputation, while up votes add considerably more (5 for questions and 10 for answers). Everyone who uses any Stack Exchange site for any length of time will gather down votes here and there. The "best" will take every down vote as an opportunity to rethink a post, and ponder how it could be improved.
That's the short version of the answer, and it has been stated before here on Meta. If you are looking for some more detailed explanations of where you could look, read on!
Why Might Someone Down Vote?
There are many reasons someone could down vote, which might include:
There are other less 'legitimate' reasons someone might down vote your post, but it's generally not helpful to spend too much time thinking about those. For instance, if you see a large number of down votes across many different posts of yours in a short period of time, it's possible you have experienced something we call "Serial Down-Voting". This post does not address that situation specifically; please see What do I do if I suspect someone has downvoted a lot of my posts?
Otherwise, when you get a down vote, consider if any of the above reasons could possibly apply to your post, and consider if you can improve it in relation to that issue. Even if that's not why the person down voted, you will end up improving your post!
Your Post Does Not Show Enough Research Effort
This is literally one of the things mentioned when you hover over the down vote arrow, and it's possible this is the most frequent reason for down votes on questions. How much effort did you put into solving your problem/answering your question before posting? Most Stack Exchange sites expect questions to be based on well-researched issues, and to reflect the effort you have made, so people posting answers don't waste their (and your) time covering ground you've already been through. So be sure that 1) you have spent reasonable effort trying to find an answer yourself and 2) that your post reflects that effort.
If you simply say something vague like "I have searched online, but couldn't find an answer", that might get classified as showing a lack of research effort - anyone can add this to their post, regardless of how little research effort they've done. Include links you've explored, stating how these didn't help, show some code that didn't work, and how it failed - while including these things may seem pointless to you, it's essential to show us that you've actually tried to find an answer yourself - many may not look kindly on you if you appear to be using Stack Overflow to do your work / thinking for you - it's here to help you do it.
They Disagreed with Statements You Made
Consider carefully; is your post factually accurate? Check each and every fact you have included, and consider linking to authoritative resources to back up your claims. Check your big facts and your small facts. Even if something you mentioned is only tangentially related, be sure you have the details of those facts correct, as well.
They Disagreed with Opinions You Expressed
Most Stack Exchange sites do not encourage questions/answers based on opinions. Expressing an opinion that someone else might disagree with is a surefire way to invite someone to down vote. Was your opinion vital to the post? Could it be removed or its applicability limited, such that those with an opposing opinion are not encouraged to down vote?
They Disagreed with How You Presented Your Post
Keep in mind that you are wanting people to have a positive reaction to your post; to answer your question, or to up vote your question/answer. Be sure you have not expressed yourself negatively. Did you rant about the technology you are using? Your post is being read by people who use that technology every day. Yes, your rant may find a great many people who agree with your point of view, but it will also find some who disagree, and will vote accordingly.
They Disagreed that the Information You Presented was On-Topic
For questions, be sure you have read the FAQ of the Stack Exchange site on which you are posting. Think about what is posted there according to both the letter and the spirit, and be open to being wrong - and being told so. Off-Topic questions will usually get voted to be closed/migrated, and sometimes people will leave comments letting you know it is off-topic. But also, some people will down vote such a question. If this is why your question was down voted, it will likely also be voted to be closed. Be open-minded in such a case; listen to what those who comment have to say, and if you really still have a doubt, consider going to that site's Meta to inquire about the question's appropriateness on the site in question. Make your case in comments on your answer, but beware getting involved in an extended 'debate'.
For answers, keep in mind that most Stack Exchange sites expect answers to specifically answer the question that was asked. Perhaps you think the person has a different problem than they are expressing in their question, and so you are trying to get "to the root of the problem". Be mindful if you do this, as some will not see the connection at all, and will think your answer is simply off-topic. Also note that you might be wrong in your assumption about where the real problem is. Either way, someone might down vote your answer if they think it doesn't answer the question at hand.
If you are very sure that you have identified a real, unspoken issue in a question, it's usually best if you first answer the question they are asking briefly and correctly, and then explain why you think their issue might be something else... then explain that answer. This makes sure that people won't think you simply ignored the question and posted what you want. But note: someone might still down vote if they think your assumption is wrong.
Should You Ask People to Explain Their Down Votes?
Some users leave a comment on their post asking for the down voter(s) to explain themselves. Be aware that this may not have the effect you want. It may, in fact, just attract more down votes. If anyone responds to your query, it's likely as not to be the person(s) who down voted originally, so your response might not be as accurate as you would like.
But it could, potentially, be helpful. In theory. Maybe. Some helpful user might later come along and offer what they guess could be the reason for the down vote. Just don't hold your breath, and keep these other things in mind:
Don't take a down vote here or there personally. If you are 100% sure that your post can't be considered to fall under any of the above, just ignore the down vote. If you've gotten more than one down vote, you should probably try to improve your question - even though it could look perfect, some may be looking at it differently than you do. Even if you're sure nothing's wrong, it always good to take the time to see how your post can be improved. It can only help!