I was a long-hair male teenager in Texas and got to experience this first-hand. Besides the frequent disparraging comments from teachers and staff, I was also kicked off the track/CC team for my hair because I "Didn't match the image the school wanted to present at athletic events." I had a 4.0GPA, was active in school activities, enrolled in all AP/Pre-AP classes, and was, most importantly, good at and enjoyed running. As a freshman I ran a 5:20 mile, 12:10 two mile, and <20min 5K and was up for varsity consideration in my sophomore year. Despite this, the coach told me, point-blank, that I could only stay on the team if I cut my hair above the ear.
My parents, pissed, yelled at every school admin they could get a meeting with to no avail. Ultimately, even the principle was impotent, apologizing for how this must be "upsetting" but saying that she couldn't do anything. Apparently the athletics coordinator who made the rule didn't report to the principle, but to the district athletics office. My parents told me they would be behind me to fight it up the chain, but I decided that the experience had ruined competetive running for me and moved on.
The enforcement of white, christian, heteronormative values to teens' hair is so insideous. It is used for racism against black teens with braids, homophobia/transphobia against queer teens who don't conform with gender stereotypes, and in my case, just to be fascist assholes to a white cis-het teen boy with long hair. Nowadays I am covered in tattoos, oscillate between long/short/natural/neon hair, and have never felt like a better representative of my institution. I am about to get my PhD, was the president of my department's graduate student association, have taught and ran summer and afterschool science programs for under-represented kids, and fought for (and gotten) better compensation for graduate employees at my school.
Fuck every petty school admin who supports this shit, I am proud of my image, I am proud of teenage me for holding onto his individuality, and I hope that any teenagers in a similar situation can feel proud of themselves too, regardless of how they express.
Hair holds a deep significance for many demographic groups, often along racial lines due to differences in style and texture. This frequently involves hair length. For some people, hair has religious significance, for others it is more an expression of heritage, but opressors have forced people to cut/change their hair as a means of stripping people's cultural expression for a long time. Shaving newly enslaved black people as a means of erasing their cultural heritage goes back to the 15th century, as many groups had distinctive styles and slave owners wanted to impose conformity. Forcing Indigenous Americans to cut their hair was done to homogenize children removed from their peoples and punish/demoralize adult men, stripping both of them of an important religious and cultural signifier in the process.
A lot of modern hair discrimination has its roots in this more explicit racism, denouncing hair that isn't in line with western-european beauty standards as unprofessional, unkempt, or unsightly. Length of hair and specific styles hold value to many different ethnic groups today, just as it did hundreds of years ago. Many black people see the display of black hairstyles (including long braids, dreads, afros, etc.) as a form of cultural reclamation, many indigenous americans still view hair length as religiously meaningful, tons of Sikhs, Muslims and Jews have strict beliefs regarding hair/beard cutting, the list goes on. Forcing these people to conform or face discipline is absolutely discrimination, and these groups are often a different ethnicity or race than the person mandating the hair be cut.
Is forcing people to maintain a certain hair length always solely racist? No. It can be discriminatory in a plethora of ways. It can also be sexist, queerphobic, and/or a form of religious discrimination. I was subject to the purely sexist aspect of this by old white guys for having long hair as a white, cis-het teenage boy, no racism involved. The label for any discrimination relies as much on who is being discriminated against and how it is applied as it does the views of the person enforcing it, making it an intersectional issue
A good rhetorical example of this multitargeted discrimination would be the banning of necklaces with stars on them. Is it inherrently discriminatory on its own? Not in a vacuum, no one is born wearing a necklace with a star. But consider two major religions that involve star iconography (judaism, islam) and you can see how this rule is antisemitic and islamiphobic whithout ever mentioning jewish or muslim people explicitly. Which form of discrimination it is contextually depends on the person experiencing it. Hair is no different. Making a black guy cut his dreads/braids is both racist and sexist when viewed in this light, as it targets a cultural symbol (a black hair style) and is likely unevenly applied across genders (black girls aren't usually required to have short hair). I hope this answers your question, if asked sincerely, and here are a few sources if anybody wants to learn more:
EEOC Guidelines on Title VII protections against religious garb discriminatjon, including hair
NAACP on Black Hair Discrimination.
CNN on Native Hair Discrimination.
ACLU Article on a legal fight against sexist hair discrimination in Texas schools.
ACLUTexas Article about transphobia via hair discrimination.
1991 Duke Law piece on the intersectionality of hair, race, and gender, with the key takeaway quoted below.
"Judgments about aesthetics do not exist apart from judgments about the social, political, and economic order of a society. They are an essential part of that order. Aesthetic values determine who and what is valued, beautiful, and entitled to control. Thus established, the structure of society at other levels also is justified."