Is this legal?

I will never live in a neighborhood with an HOA.
I live in one with an HOA. It isn't terrible. The only thing I don't like is they don't allow a 3rd vehicle to park in the driveway if it blocks the sidewalk. I sorta get it, but by and large, most people walk on the street. There's some sort of trash pickup three days out of the week, so trash cans block the sidewalks.

I haven't been bothered or had any other issues with HOA or neighbors. Won't live here forever, at least I hope not. I'd love a home in the country without dealing with any sort of HOA. Definitely a goal of mine when I retire.