The court's standard for initially awarding custody is to determine the best interests of the child. In order to do this they look at several factors. The following lists some of the factors, but not all, that courts will consider.
Drug use and abuse can be a factor along with any type of physical or mental abuse. Is there a history of one parent walking out and leaving the other parent to cope with the child and the home? Which parent has the financial resources to give the child more opportunities?
Who will be able to keep the child's family most intact? Who is going to let the child speak with their ex-mother-in-law, for example? Who will not penalize the child for any adverse action on the part of the other parent.
Who is the person who takes care of the child? Who feeds the child, shops for their clothes, gets them up for school, bathes them, and arranges day care? Who does the child turn to when they get hurt?
What are the psychological and physical capacities of the parties seeking custody? The court may also consider evidence of abuse by a party against the other parent, the party's spouse, or any child residing within the party's household (including another child).
The court has the discretion to interview the child out of the parents' presence. A child as young as 5 or 6 years of age may be heard. Though it is rare the court will hear from a child under 7 years, the child's ability to tell the truth from fiction and maturity will be the guidelines for whether a child may be heard. A child of 10 or 12 years of age is certainly entitled to have their opinions heard and given weight in legal proceedings about custody. Additionally, the court has the power to appoint an attorney for the child in contested cases.
All these are factors that the court takes into consideration when making a determination about custody.