I've posted a question or an answer, and I have received one or more downvotes. 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 downvote is an opportunity to consider that perhaps your post could be improved somehow. If you are at all bothered by a downvote, I encourage you to consider the following.
(Note: if you've been downvoted on a meta site - either this site, or a per-site meta - please read the "Special note for Meta sites" at the bottom.)
First, you should never take a downvote personally. Remember that a downvote only takes away 2 reputation, while upvotes add considerably more (10). 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!
There are many reasons someone could down vote, which might include:
There are other less "legitimate" reasons someone might downvote your post, but it's generally not helpful to spend too much time thinking about those. Generally, if one of your posts receives a lot of downvotes from many different users, it's because of one of these reasons, not because the votes are illegitimate.
When you get a downvote, 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 downvoted, you will end up improving your post, and attract upvotes that will counter the downvote!
This is one of the things mentioned when you hover over the downvote arrow, and this is probably is the most frequent reason for downvotes on questions.
How much effort did you put into solving your problem/answering your question before posting? Unlike most other sites on the Internet, most Stack Exchange sites expect you to have done research into finding an solution to your issue before asking your question, and to reflect the effort you have made to try and solve it yourself. This is 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 - that doesn't actually show the research that you've done. Include links you've explored, stating how these didn't help. Show some things you've tried that didn't work, and how they 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 users may not look kindly on you if you appear to be using Stack Exchange to do your work / thinking for you - it's here to help you do it.
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.
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 downvote. 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 downvote?
Keep in mind that you are wanting people to have a positive reaction to your post: to answer your question, or to upvote 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.
Also, take care with your formatting. For example, people may downvote when you use ALL CAPS for your title or content, because this is often interpreted as shouting.
For questions, be sure you have read the help center 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. Questions that don't fit within the site's scope will usually get voted to be closed, and sometimes people will leave comments letting you know that it's not a good fit. But also, some people will downvote such a question. If this is why your question was downvoted, 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 per-site meta to inquire about the question's appropriateness on the site in question.
On meta sites, such as the one you are on now, please understand that this site is only about the site itself (so, for example, https://meta.stackoverflow.com/ is for questions about problems on https://stackoverflow.com/, etc). Make sure the site where you are asking is actually the one you meant to post on, and actually accepts questions about the topic you tried to ask about.
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 doesn't attempt to answer the question. Also note that you might be wrong in your assumption about where the real problem is. Either way, someone might downvote 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.
Some users leave a comment on their post asking for the downvoter(s) to explain themselves. Be aware that this may not have the effect you want. It may, in fact, just attract more downvotes. If anyone responds to your query, it's likely as not to be the person(s) who downvoted originally, so your response might not be as accurate as you would like.
But it could, potentially, be helpful. Some helpful user might later come along and offer what they guess could be the reason for the downvote(s), or suggestions on how to improve your post. Just don't hold your breath, and keep these other things in mind:
Don't take a downvote 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 downvote. 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!
Votes are slightly different on meta sites. On meta sites, you may be more quickly down voted because people simply disagree with your thoughts on a topic. For example, on questions tagged feature-request, others may downvote if they disagree with your proposed feature. This is a valid reason for downvoting on a Meta site. You may still apply the ideas above, but just understand that opinions and thoughts are more freely expressed on Meta sites, both in posts and in votes.
Also, note that on per-site metas, as your reputation from them is based on your activity on the corresponding main site, you won't lose any points from downvotes on those sites.