Yes, if it is written into your contract, your employer can specify how you dress at work.
Your contract may state that you need to dress in a certain manner, or wear a uniform. This also includes documents such as the staff handbook, which makes up part of your contract terms.
Your contract might state that you need to dress 'smartly', rather than specifying any particular garments. If this is the case, you will need to interpret the instruction with your employer, as you might well have conflicting ideas of what counts as 'smart'.
Further your employer should try to avoid including elements in a dress code which would unjustifiably conflict with someone's religion or religious beliefs. For example, a dress code forbidding headwear would disriminate against male Sikhs who must wear a turban.
An important exception to this is that your employer may not specify dress conditions that would be directly or indirectly discriminatory for men or women at work.
Just One More Click: Doggy drama about staying safe online at work.