HTML <audio> in vertical writing mode

Nov 26, 2026

In the past, maybe a year ago, after seeing a demo, I tried flipping a webpage to vertical writing mode.

At the time, I thought I had a problem with my image CSS in vertical mode that required a JavaScript fix. But I must have made a stupid error, because when I tried it again yesterday, `max-inline-size: <number>%` and `max-block-size: <number>vb` “just worked” in both modes.

So I tried to add <audio> to the mix.

The outcome I wanted was the equivalent of (something like) `audio { width: 100% }` in horizontal mode and `audio { width: 66.67vw }` in vertical mode.

But one:

Safari and Chrome don’t rotate the audio player vertically in vertical writing mode, which might be fine if they still responded to `audio { inline-size: 100% }` by growing the player horizontally; instead, they keep the player at its default size, and, for some reason, move it to the bottom of its container.

But this doesn’t matter, because two:

Firefox “hardcodes” <audio> to always be `horizontal-tb`, which means any cross browser solution requires making <audio> always `horizontal-tb` in Safari and Chrome, too.

Anyway, one solution is using a <div> wrapper, for example:


<style>
	html { writing-mode: vertical-rl }
	
	div:has(> audio) { max-block-size: 66.67vb }
	
	audio {
		writing-mode: horizontal-tb;
		inline-size: 100%
	}
</style>

<figure>
	<div>
		<audio>
			<source src=example.mp3>
		</audio>
	</div>

	<figcaption></figcaption>
</figure>
Not a garden of pure CSS-only logical properties like I got with images, but I’m okay with it, I guess. After all, I still need a <div> wrapper to apply `overflow-inline` to <table>.

Another solution:

<html class=vertical>

<style>
	.vertical {writing-mode: vertical-rl }
	
	audio { inline-size: 100% }
	
	.vertical audio {
		writing-mode: horizontal-tb;
		inline-size: 66.67vi
	}
</style>

<figure>
	<audio>
		<source src=example.mp3>
	</audio>

	<figcaption></figcaption>
</figure>