I think that there was even a British law at the time that made it illegal to depict homosexuality in children’s media. I might be misremembering though.
That was definitely preventing depiction of homosexuality in educational materials, but I would have to check if that expressly extended to children’s literature.
Cartoons, children’s films, TV shows, comics, yes, I can see that even if it wasn’t illegal that the makers would err on the side of caution and avoid that subject as it was way more likely that parents would notice that kind of stuff and complain.
Even so, if one directly compares HP to equivalent literature and media, e.g. Jennings, The Bash Street Kids, Mr Chips, The worst witch, the sexuality of the teachers is never a concern.
Occasionally teachers will be depicted as being in a straight marriage, but A: the fucking majority of people are straight, B: the spouse character would just be a prop more or less, except in rare cases as I believe in Mr Chips, his wife is an influence on how he views corporal punishment in the school system.
Maybe, in the more mischievous examples, a teacher’s wife would be the target of a prank or similar related plot device but other than that, whether the teacher was gay or straight wasn’t especially important to the overall story.
Yes, I am well aware that British schoolkids would be fucking merciless to a teacher that was a known queen, but even in Jennings era that would have come off as more mean spirited than some forgivable boys will be boys hijinks.
I actually vaguely recall a Grange Hill (long running British children’s soap opera set in a school) storyline about a gay teacher which is ultimately resolved by the boys football team defending him from a rival school team during a match.
There was also a one sided gay love situation between two boys in Byker Grove,(similar idea to GH but set in a youth center rather than a school).
Both of these must have been in the 90s, and definitely predated Harry Potter, so maybe there had been some relaxation.