Upvote:8
No, there are no dress codes at temples or shrines. The Japanese attitude to religion is very relaxed... and simultaneously strict, as entry to anything even vaguely holy is generally entirely prohibited.
That said, the prevailing Japanese opinion is that men's shorts above the knee are for elementary school students and the beach, although nobody will find you wearing them offensive, just vaguely ridiculous.
One nice although by no means obligatory gesture on entering a shrine is quickly purify yourself at the water basin (chΕzuya). The standard ritual is as follows: