logoalt Hacker News

Cort3z05/04/20251 replyview on HN

Kind of serious question. Do we have any alternatives to html? If not, why? It’s essentially all html. Yes, browser will render svg/pdf/md and so on, but as far as I can tell, it’s not what I consider "real web" (links to other documents, support for styling, shared resources, scripting, and so on ).

I would have loved for there to be a json based format, or perhaps yaml, as an alternative to the xml- based stuff we have today.


Replies

panny05/06/2025

>links to other documents, support for styling, shared resources, scripting, and so on

SVG supports all those things. SVG's use element can do exactly what the OP is talking about. You can put HTML in SVG and SVG in HTML. SVG is just markup exactly like HTML. SVG supports JavaScript and stylesheets. SVG can put text on a curve and other stylish things that boring boxy HTML cannot accomplish.

https://www.w3.org/2002/Talks/www2002-svgtut-ih/hwtut.pdf

Read it. Ch 11 shows you how use can import chunks of other SVG. Ch 12 is JavaScript. You can inline it in your html and style it with CSS just like any of the other tags in html. Once you know SVG, you can hand generate more compact images than anything created by something like Inkscape which just uses path elements for everything. For example, you can do a UPC barcode with a single SVG line element using a wide stroke and a stroke-dasharray. See chapter 8.