That’s how the law is written in Texas, although the maximum difference in age is 3 years, rather than 2.
That is similar to the law in California, although here the law states that one party must be of age.