Various terms are used to talk about sex and gender:
Sex refers to a person's anatomy: male, female, or not clearly male or female (ambiguous genitals, or intersex).
Sexual identity refers to the sex to which a person is sexually attracted (if any).
Gender identity is how people see themselves, whether masculine, feminine, or something else (sometimes called genderqueer, nonbinary, or agender), which may be somewhere in-between, a combination of masculine and feminine, or neither or which may frequently change.
Gender role is how people present themselves in public in terms of gender. It includes the way people dress, speak, wear their hair—in fact everything that people say and do that indicates masculinity or femininity.
For most people, gender identity is consistent with their anatomic (birth) sex and their gender role (as when a man has an inner sense of masculinity and publicly acts in masculine ways).
Gender identity is well-established by early childhood (18 to 24 months of age). During childhood, boys come to know they are boys, and girls come to know they are girls. Children sometimes prefer activities considered to be more appropriate for the other sex (called gender-nonconforming behavior). For example, young girls may like to play baseball and wrestle. Young boys may play with dolls and prefer cooking to sports or to rough types of play. Usually, this behavior is part of normal development. It does not mean that children have a gender identity problem as long as they identify themselves as and are comfortable with being their birth sex. Most boys who prefer activities considered more appropriate for girls do not have a gender identity problem when they grow up. However, many of those who consistently prefer these activities are more likely to be homosexual or bisexual as adults.
Children born with ambiguous genitals usually do not have a gender identity problem if they are decisively reared as one sex or the other, even if they are raised in the gender role that is opposite to their biologic sex pattern. Whether genital surgery is appropriate for children and infants with visibly ambiguous genitals is controversial.
Sometimes people feel that their gender identity and their anatomic sex do not match. Sometimes this feeling of mismatch causes significant distress and/or impairs the ability to function. In such cases, the condition is called gender dysphoria. People with gender dysphoria may need to be evaluated by a health care practitioner.