Update: 1⅓ More Solutions

Nov 26, 2026

A CSS-only solution:

<style>
:root{ --wm: vertical-rl }

html{ writing-mode: var(--wm) }

audio { 
	writing-mode: horizontal-tb;
	inline-size: 100% 
}

@container
	style(--wm: vertical-rl) or
	style(--wm: vertical-lr) {
		audio { inline-size: 66.67vi }
}
</style>

Live example: https://justin-reeves.net/26/vertical-rl

I came across that approach while investigating the issue, but rejected it as “inelegant” and “worse than JavaScript,” but had second thoughts, as it fully separates (the concerns of) CSS and HTML. Though I wish it didn’t require the custom property indirection.

A Chrome-only version:

<style>
:root{ --wm: vertical-rl }

html{ writing-mode: var(--wm) }

audio { 
	writing-mode: horizontal-tb;
	inline-size: if(style(
		(--wm: vertical-rl) or 
		(--wm: vertical-lr)
		):
		66.67vi; else: 
		100%
	)
}
</style>