casually replacing <svg display="none"> with <svg style="display: none"> this morning
I don’t need to git blame the commit from 5 years ago — I already know who did it
(…it me)
Zach Leatherman 2525 replies 4242 likes11 quote Original on Bluesky25 replies
blocked
if you can’t handle me at my JavaScript then you don’t deserve me at my HTML
I feel both offended and seen.
you’re in the right place 😅
how dare my personal web site not undergo a vigorous and lengthy code review process
it's fine
[display=none] { display: none; }
or if you wanna get "snazzy" with it 😮
[display] {
display: attr(display type(<custom-ident>), block);
}THIS IS A CURSED SOLUTION and I’ve shipped it to all of my web sites thank you
gonna go create a Tailwind-like solution powered by HTML attributes instead now 💀
…wait
headgust™
this actually kind of exists with unocss.dev/presets/attr..., but it gets compiled away lol
yeah – but the power part here would be it's a runtime thing
you could allow a defined set and then let people jus' throw updates in the HTML with it all covered by that one line 😅
mayhem
had some fun messing around with this today :) github.com/uncenter/att...
love it - the name is brilliant 😅 sounds like a cleaning product haha
read the README, could technically purge this as well which would make for a real small stylesheet 🤔
Maybe I’m reading too much into this, but wouldn’t you prefer to do it like this?
<SVG class=“youKnowWhat”…>
.youKnowWhat {
display: hidden;
}plenty of fine ways to do this (though you’d want `display: none` not hidden there). `<svg hidden>` might be the best one!
in this specific case it’s for an SVG spritesheet.
<svg display="don't">
...but really: don't forget about the `hidden` attribute.
if I could pin a reply…
so… this might be a stupid question but why doesn’t <svg hidden></svg> hide the svg 😅 codepen.io/zachleat/pen...
Odd! Looks like default browser styles aren't including `display: none` for svg[hidden]. Might only apply to HTML elements by default, as SVG2 spec doesn't list it under the attributes.
www.w3.org/TR/SVG2/stru...Adding `[hidden] { display:none }` to CSS will do it, but maybe that's wrong for this
Hidden spec for reference: html.spec.whatwg.org#the-hidden-a...
Doesn't directly address <svg> that I can tell. Hard to say what the broswer's choice is there.
maybe `svg[hidden] { display: none; }` is a good candidate for the css reset stylesheet
Not sure if it’s still an issue when using <use> with a svg sprite/asset - but back in the old days display:none broke <defs>
style=”width:0;height:0;position:absolute;” focusable=“false” is what I’m using (maybe I ought to do a do-we-still-need-this l)If you didn't not look at your old code and consider it bad, it would mean you hadn't learned anything 😀