HACKER Q&A
📣 kizer

Why not use SVG for everything?


Some context: It seems like web development is stuck in a frustrating limbo between utilizing HTML presentationally, while trying to maintain a balance with ARIA/accessibility and so-called semantic markup. There's a dissonance that bugs me - and of course call out any ignorance or insularity here - but I really wish there were a purely graphical/animated layer, with a semantic construction of sorts "super-imposed" on top to ensure accessibility and bot-digestible metadata.

Brings me to the title. Aside from wrapped text, this graphical layer could be pure SVG + CSS&JS. Why constrain designers to little CSS hack triangles and circles when there's an almost limitless vector graphics technology available instead?

I predict even with Houdini, CSS won't be rich enough to eliminate presentational markup for complex web applications. I know about role="presentation", but that seems to be an awkward compromise to avoid an explicit separation of concerns:

'Inspect element' any sophisticated web app and you'll see divs inside of divs inside of divs with class="color-blue border-2px border-gray background-number-seven". Slight exaggeration, but the separation of concerns doesn't exist.

I know the spirit of the web is "hackish" in that the standard quo is more of a gradual, messy evolution that gets there eventually rather than giant leaps which may not "stick the landing". However, to me it appears that some organization of _presentational_ aspects in particular is really needed. I know WebComponents, Houdini, and other "rationalize the platform" efforts' goals include this in part, but it doesn't seem like a nice graphical/animation layer which would sidestep DOM performance issues is in the cards.

This was off the top of my head, but I hope I got the gist across. I welcome any feedback.


  👤 qppo Accepted Answer ✓
Have you ever read or attempted to implement a portion of the SVG specification?

It's absurdly complex, and there is little guarantee that the SVG spec is implemented completely and identically in different environments. I know of several native GUI SDKs that do not support a large portion of the spec.

Even something that should be easy like doing a wireframe or mockup in Sketch, exporting to SVG, then displaying that exported SVG in a browser on the same machine can display jarring errors in the rendered image.

And most of the cool shit in SVG - like embedded JS and the filters spec - are where those issues rear their heads.

What I'm saying is that SVG is as much a shitshow as HTML. It's just HTML with additional drawing semantics anyway.


👤 m463
I've always thought SVG should be more a part of things, but I think it's not as mature. If there were more SVG authoring tools it might help (symbolic ones).

But it is pretty cool:

https://upload.wikimedia.org/wikipedia/commons/6/6c/Morphing...

From: https://en.wikipedia.org/wiki/SVG_animation


👤 kizer
I 'inspect-element'd some random pane on Facebook: https://imgur.com/a/qecS7gJ

👤 seanwilson
> Aside from wrapped text, this graphical layer could be pure SVG + CSS&JS. Why constrain designers to little CSS hack triangles and circles when there's an almost limitless vector graphics technology available instead?

Could you expand on what you'd gain that isn't being done already? I'm not following what you mean here.

Web developers already use SVG for complex vector illustrations + some JS or CSS to animate the SVGs, coupled with CSS for simple shapes (like circles + rounded rectangles with shadows), and CSS for responsive layouts (SVG doesn't have anything similar to CSS in terms for responsive logic or layout logic as far as I know).

This works well enough, and for example you can replicate most UIs you'd see on different platforms without getting too crazy. I feel most UIs people want to build just really are composed of mostly rectangles, oval and circle, some layering and some shadows - CSS alone is decent at this.


👤 perilunar
You can build websites already in SVG with no HTML — not even a wrapper page. You just need to configure the web server to serve SVG instead of HTML by default. e.g. in Apache:

  DirectoryIndex index.svg index.html ...
You can also embed HTML inside SVG if you want, or HTML in SVG in HTML. I've only tried it for small demos and not seen it (SVG-only sites) used in the wild, but it does work.

👤 JMTQp8lwXL
Additional discussion on this topic from ~2 weeks ago: https://news.ycombinator.com/item?id=23385380

👤 gjvc
Are you saying that "Browser DOM is the root of all evil." ?