There are certain manners you are supposed to follow when you are visiting tatami rooms in formal settings, for example, when you go sightseeing to old Japanese houses, visit shrines and temples, and also when you eat at high-class Japanese style restaurants.
You are not allowed to enter with your shoes or slippers on!
In Japanese houses, you must take off your shoes before you go in regardless of whether it is a tatami room or not. When you go in, people often invite you to put on slippers. However, you cannot go into a tatami room with these slippers on. If you walk on tatami mats with slippers on, you will damage the tatami mats, so make sure you take off your slippers before you go into a tatami room. Moreover, it is not appropriate to go into a tatami room barefoot in a formal setting, for example, when you get invited. If you wear sneakers and sandals without socks, make sure you carry socks with you.
Do not step on shikii and the edges of tatami mats.
There is a section with wooden rails between Japanese rooms and hallways called shikii. Stepping on it is not considered good manners in Japan. You are not supposed to step on the cloth on the edges of a tatami mat, either.
There are several stories about why you should not step on shikii and on the edges of a tatami mat. One of them is that shikii gets damaged easily since it is made of wood. And if the wooden rails get damaged, it is difficult to open and close the sliding doors called husuma. The edges of tatami also gets damaged very easily so they are reinforced with cloth. Therefore, you can make tatami mats last longer by not stepping on the edges.
Moreover, some venerable houses have their family crests sewn into the edges of tatami mats. A family crest is a symbol of the family, so it is rude to step on them.
Also, one unique theory is that when there were still samurais, the ninjas hiding below the floors might stick a sword through the gaps between shikii and tatami mats and try to kill samurais, so people avoided stepping on shikii and the edges of tatami. For the same reason, there is an old saying that you cannot live long if you sleep with your head towards kamoi, the upper wooden rails of a sliding door. Although in this day and age, there are no samurais and you do not have to worry about ninjas hiding below the floor, it is courteous not to step on shikii and the edges of tatami.
Manners for when you sit or walk on tatami mats
When you sit in tatami rooms, you usually sit on cushions. Cushions are in a way spots indicating where to be seated, so you should not change the positions of the cushions without asking or bring them closer when you take a seat. Moreover, you should not step on them with the soles of your feet. When you walk, walk on tatami mats, and once you reach where you sit, sit on cushions. That is a rule.
When you are seated, stay seated with your knees on the floor, folding your legs underneath your thighs, while resting your buttocks on your heels until you are told to break that position and relax. After someone has told you to break your position, you can sit in a cross-legged position if you are a man, but it is not appropriate to sit down hugging your knees close to your chest. If you are a woman, it is not appropriate to sit cross-legged, or with your knees close to your chest, so please sit down with your knees on the floor, folding your legs to either side underneath your thighs with your buttocks resting on the tatami mat.
The reason why men and women are supposed to sit differently is because the customs from the times when people were wearing kimonos have still remained. When wearing kimonos, men were wearing loincloths as underwear, but women only had a piece of cloth wrapped around their waist. Therefore, it was considered inappropriate for women to sit down with your legs open.
These are manners you are supposed follow only in formal settings, and so you can sit in a less tiring and relaxed position when good friends of yours invite you to their houses in an informal setting.