That delicacy, for Marshall as for many of the others, was a stopgap solution to the existential problem of the closet: How do you grow up when you cannot fully and genuinely present yourself as an adult? (In deference to his mother, Marshall’s 1992 obituary omitted his longtime partner — and listed a brain tumor as the cause of death instead of complications from AIDS.) Even the gloomy Jeremiah of children’s literature whom Marshall lovingly called Morose Sendak was too cowed by his parents to come out publicly until long after both were dead. You can feel the crosscutting energies of that conflict at the wild heart of his greatest works, which are full of rage at punitive elders but also a grudging respect, because their restrictiveness is what forces the child’s imagination to flower. Nor is that imagination asexual; Mickey, the stark naked hero of “In the Night Kitchen,” is baked into a cake batter by three adult men. Sendak presses right up against the taboo, allowing him to write about sexuality and to access its energies and disappointments safely. Otherwise he would never have dared to publish such a story or, for that matter, needed to write it.

CLOSETS TEND TO be small, lonely places — a fine fit for children playing hide-and-seek, if not always comfortable for adults. Yet they are also, it seems, conducive to literature, in the way almost any constraint is. Today, Mickey would just go to Bennington and wind up marrying that hunky fireman.

Back then, though, if Sendak and the others got any pleasure from their secret identities, they suffered for them as well. How often did they have to put masks on in public, then take them off to live and write? Masks were, in fact, the main motif of Marshall’s “Miss Nelson” series, written with Harry Allard between 1977 and 1985, about a grade school teacher’s increasingly unorthodox methods of maintaining order and morale. In the first book, “Miss Nelson Is Missing!,” she decides to teach her ungovernable class a lesson by vanishing — only to reappear, the next day, disguised as the worst substitute ever. This Miss Viola Swamp is a “real witch,” complete with fright wig, honker and wart: “If you misbehave,” she warns, “you’ll be sorry.” At the end, once the class is tamed, Miss Nelson retires her Swamp costume, hanging it in her closet and saying, with a smile, “I’ll never tell.”

Not many descriptions of gay “passing” get deeper than that: There’s the delicious victory and, unspoken, the realization that maintaining the victory means maintaining the ruse. Yet because these authors were out to entertain children — it’s no accident the books remain popular — they never tip into the maudlin; if anything, they lean into camp. By the end of the “Miss Nelson” series, even the school principal is in drag.

Such winks may be useful in distracting adults. While studying the Easter eggs in Mickey’s night kitchen (Sendak has even hidden the Brooklyn address of his childhood home in the gutter between two pages), a parent may not focus so much on the weirdness of what’s going on. But children aren’t distracted by such things. Instead, they track the jokes and the emotions, which in the hands of these authors are much the same thing. Another of Lobel’s characters, the bachelor owl of “Owl at Home” (1975), is almost a caricature of loneliness: His only friend, the moon, is inconstant; he makes tea from his own tears.

That he’s not in fact a caricature is the result of Lobel’s careful modulation of tone, which turns the pathos inside out. As someone who had experienced the forced deprivations of the closet, he was perfectly suited to meet sensitive children on their own ground of powerlessness and unbelonging, and to show them how such feelings can be mastered. Owl is lonely, yes, but jovial, natural, staunch, a survivor. He and George and Martha and Max and Mickey and Frog and Toad and Oliver and Harriet are like celebrities in an It Gets Better public service announcement, armed with wit instead of condescension. They whisper from the other side of the struggle for authenticity, saying, “You are not wrong, dear one. Everyone else is.”

But if the creators of these characters were thus the ideal people to speak to, and for, children, they did so at a cost. The world they imagined had not yet come to pass; if it had, they wouldn’t have had to imagine it. No wonder Nordstrom, without whom the golden age of children’s literature would not have happened, spent so much time in her letters carefully nursing her authors’ neuroses. (“Thanks for your card telling me you are having a nervous breakdown,” she wrote in 1972 to Gorey, who was late with a manuscript. “Welcome to the club.”) She needed them calm enough to create, but not so calm as to have nothing to say.