A ball that touches any part of a line is in. It counts as touching the court that the line is part of.
That is why a ball that only brushes the baseline, the sideline or the service line is good.
The whole line is part of the court. Even a ball that touches only the edge of a line is in.
During a rally, the ball can touch the net, the posts, the strap or the band. It is still good if it passes over and lands in the correct court.
A ball that touches the net in a rally and falls on the player's own side is a loss of the point for the player who hit it.
If the ball lands in the correct court and then touches a permanent fixture, such as the fence or the umpire's chair, the player who hit it wins the point.
If the ball touches a permanent fixture before it bounces, the player who hit it loses the point.
Permanent fixtures include the backstop, the fence, the net post, the umpire's chair and the spectators.
A ball can go around the net post, outside the net, as long as it lands in the correct court. It does not have to pass over the net itself.
This shot is called an "around the post" shot. It is legal, and can be hit below the height of the net.