When the parents of a child get divorced or separated, or were never married in the first place, the parents have to decide who will be primarily responsible for raising the child. After all, children still need to be raised, and most experts agree that it's better for children to be raised by both of their parents than by only one of them, in most cases. This doesn't change when the relationship between the parents breaks down. And, thankfully, most parents are sensible enough to recognize this fact, and do what they can to ensure that the problems that exist between them affect their children as little as possible.
When the parents can't agree on child custody rights by themselves, your local family law court is going to have to make a decision for you. It's important to note that the court will not give much weight to the preferences or desires of either parent when making this decision. Instead, the court will consider the well-being of the child. In determining what decision is in the best interests of the child, the court will consider many factors, and work from a few starting assumptions.
First, unless there is strong evidence to suggest otherwise, the court will assume that it's better for the child to have both parents involved in his or her life, than to only have one. Of course, the facts of a particular case might work against this assumption (if one of the parents has a history of neglect or abuse, for instance).
Grandparent Custody Rights
In some cases, when neither parent is able to properly care for the child, a court might grant custody rights to the child's grandparents, if it can be shown that giving grandparents custody rights is in the child's best interest, and they are the closest living relatives who are best able to take care of the child.
Step-Parent Custody Rights
Sometimes, when one parent passes away, or is no longer in the picture for another reason, the parent who has custody of the child will re-marry. If this happens when the child is still very young, the step-parent may want to seek custody rights. This can often be accomplished by the step-parent legally adopting the child. In this case, the step-parent will have custody rights identical to those enjoyed by a biological parent.