Many, but not all, states have a close-in-age exemption to their age of consent law. Also known as "Romeo and Juliet laws", these exemptions exist to protect youths close in age who are engaging in sexual relationships from prosecution even if they are technically in violation of the state's age of consent law.
Close-in-age exemptions are designed to include situations in which both partners are under the age of consent, or one partner is older then the age of consent and one partner is younger (but they are close to each other in age). While the exact age range and details of the close-in-age exemption vary state by state, most allow for all people within 3-4 years of age of each other to legally engage in consensual sexual acts.
Close-in-age exemptions may completely allow close in age sexual contact, or it may only prevent prosecution (while technically keeping such contact illegal). Some states without close-in-age exemptions may allow close in age, consensual contact as an acceptable defense in court if one or both consenting parties are prosecuted.