What is the tourist tax?
The line on your bill is actually two small taxes stacked together — the taxe de séjour for the city and the taxe de promotion touristique for the country. Together they run from a few dirhams to thirty-odd per person per night, depending on the city and how grandly your accommodation is classified. A palace pays palace rates; a guesthouse pays guesthouse rates. Children usually ride free or reduced.
The part that catches people out: many riads quote rooms without it, since the booking platforms display it inconsistently, and then ask for it in cash at checkout — even when the room was prepaid online. That's normal, not a hustle; the riad passes it on to the city and needs its paper trail. If you like your surprises elsewhere, ask at check-in how much the total will be and set the coins aside with your passport.