While each company has a different idea of what its employees should wear to work, employers usually have the power to enforce some kind of dress code.
But with this ability come legal risks if the dress code isn’t applied equally to male and female employees.
Of course, the dress codes for men and women can’t be completely identical. For example, one very common difference is men only being allowed to wear pants, while women are able to wear dresses and skirts as well as pants.
These differences are widely considered reasonable, but things can start crossing into discrimination territory