Schools in England have been given new advice stressing that uniforms must be reasonably priced and widely available.
Uniforms must not be used as "back door selection"
Ministers have released new guidance on their rights and responsibilities.
It says pupils' religious beliefs should be considered, but the rights of an individual should be balanced against the whole school's interests.
Uniforms should not be so expensive that they put off poorer families, thus creating "back-door selection", and should not be limited to one supplier.
The advice has been updated following a consultation. Recent years have seen several legal challenges to school uniform rules, most controversially concerning the wearing of veils or niqabs.
The guidance notes that the Human Rights Act of 1998 protects the right to "manifest one's religion or beliefs" and says schools should "act reasonably in accommodating religious requirements".
However, it goes on to say that "freedom to manifest a religion or belief does not mean that an individual has the right to manifest their religion or belief at any time, in any place, or in any particular manner".
There could be other considerations which might outweigh the needs of particular groups - such as matters of health and safety or related to teaching in general.
"If a pupil's face is obscured for any reason, the teacher may not be able to judge their engagement with learning, and to secure their participation in discussions and practical activities," it says.
Another factor might be "the need to promote harmony between different groups represented in the school".
With schools under pressure to encourage children to walk to and from school, the guidance also suggests they should consider including light colours or reflective materials in the uniforms they choose.
There has been criticism from some campaign groups about the cost of uniforms. Poorer families, they say, can be put off applying to a good school because of the price of uniforms.
The guidance stresses that uniforms should be widely available and reasonably priced - not limited to one chosen supplier or the school itself.
It also says there should be schemes to help poorer families recover the costs of uniform and that these should be run discreetly for children who receive free school meals.
Uniform guidance: key points
They must be affordable,
They must be widely available
No exclusive deals with suppliers
Schools could face sanctions
Schools should consult with community
Human rights balanced with the general good
Schools must act reasonably over religious requirements
Schools are warned they could be open to legal action if they have exclusive contracts with suppliers and that they have a statutory duty under the School Admissions Code to ensure that their policies and practices do not disadvantage any children.
Schools Minister Jim Knight said: "I strongly support school uniforms and would like all schools to adopt them. They can instil pride and unity, support a strong school ethos and prevent the jealousy, rivalry and conflict that can arise when children wear different clothes.
"But the cost of uniforms must never be a barrier for poorer families. There's an important balance to be struck between developing a smart, comfortable uniform and burdening parents with needless expense by insisting on bespoke designs, for instance.
"We will take action where schools have a uniform policy that is needlessly and prohibitively expensive, while the OFT has already written to schools warning that exclusive contracts with suppliers may contravene the Competition Act."
Steve Sinnott, general secretary of the National Union of Teachers, welcomed the guidance. He said: "Expensive school uniforms have often been used as a form of 'back-door' selection.
"The new guidelines send a clear message that schools will not be able use their choice of uniform as a means to discriminate between the haves and have nots."
Katie Lane, from Citizens Advice, said schools had ignored previous instructions to make uniform policies fair.
She said: "We therefore very much welcome the fact that the government has pledged to take tougher action against schools to make uniform policies more realistic and affordable".
A school's right to send children home - briefly - to put on the correct uniform or adjust their appearance in line with school rules is confirmed in the guidance.
Schools also have the right to exclude a pupil for uniform offences - but only if he or she is repeatedly defiant.
Schools should be considerate and reasonable and look discreetly at the circumstances of an individual case.
The guidance says: "For example, their uniform may have been lost, stolen or damaged. Sending the pupil home or excluding them may not be appropriate in every case.
"If a pupil is not wearing the correct uniform because their parents are in financial difficulties, a school should be sensitive to the needs of the pupil."
It is the task of a school's governing body to decide whether or not a school has a uniform and if so, what it should be.
The guidance stresses that consultation by the school is crucial - suggesting that by talking to parents, prospective parents and groups in the wider community, a school should be able to head off potential problems.