Yeah, but that’s more markup. Markup generally isn’t cached as well as scripting.
That separation of concerns pays dividends in ways people don’t think of. If it’s a frequently visited page you end up saving bandwidth by not putting things in the markup, for the small penalty of a slight hit at cache-empty first-load.
One of the MANY reasons that garbage like Tailwind, Bootstrap, BEM, and so forth result in larger slower websites. Presentational classes and endless pointless classes for nothing provide nothing of value but dragging things back to the worst of HTML 3.2. Pissing on caching models being one of the root causes of what makes them so dumbass.
We can say much the same of scripting-only code in the markup… or in this case non-scripting code.