When your dog wags his tail, it doesn't always mean that he's happy -- in fact, it can indicate quite the opposite. Just like your eyes and mouth are capable of expressing different emotions, your dog's tail is a valuable tool for nonverbal communication. If you pay attention to the movements and position of his tail, you can better understand what he's feeling and what he wants to express to you.
Not all dogs have similar tails, but they all have a natural position for holding their own. For example, some dogs have long tails that tuck between the legs, while others sport tails that droop behind them. Somewhere in the middle, dogs like pugs have irregularly shaped tails that curl upward. When your dog's tail is in its natural position and not moving, it means that he's relaxed and calm.
If your dog's tail gently sways back and forth while hanging down, it's a friendly sign. If he feels very welcoming, safe and confident, it may wag in broad, sweeping strokes. It he feels more cautious, like when he is happily meeting another dog but not yet sure of what to expect, his wags may be smaller and more restrained. In any case, if the tail is low, loose and wagging, your dog does not feel aggressive or threatened.
High and Rigid
When your dog raises up his tail and wags it, keep a close eye on him -- this can indicate aggression or hostility. Holding his tail up rigidly is simply a sign of arousal, but if he wags it back and forth while it's rigid, he's sending a warning. Look for other signs of aggression, like an unwavering gaze, bared teeth or raised hackles. If his tail is only half raised, he feels antisocial, but in a way that betrays insecurity and anxiousness more than hostility.
The faster your dog wags his tail, the more excited he is. When the wagging reaches a particularly high speed -- look for quick, short movements -- it means that your dog is ready to spring into action. Depending on his personality and the situation, this can mean either fight or flight, so be prepared to intervene if he's wagging his tail this rapidly in a situation with another animal -- he may need to be restrained or otherwise removed from the situation.