today i learned: svg files are literally just html code
-
technically HTML is not XML.. XHTML is, but HTML can be invalid XML.
It annoys me that you aren't supposed to close input tags. At least browsers tolerate self closing them even if it is out of spec.
-
for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it.
Isn't that how it already works? GNOME system icons are all SVG - that's what allows them to change colors when you change themes or switch between light and dark mode.
There are both, PNG as standard sizes and the SVGs. I believe the DE pulls the 32 48 256 pixel pngs so no addition rendering is needed.
-
what the heck!! that is so wild, mind blowing, i know the main difference between raster graphics and vector graphics was the quality but not more, i had no idea svg files actually used html code and pretty much could be modified using only text and amazing code woa!!! this opens up the possibility for so many things on linux i think, for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it. svg can be given a lot of attributes like movement, mouse hovering, change color, change anything. and most svg files are still under a megabyte. wow.. please let me know other fun facts about svg or eps files. i really like doing graphic design on linux and inkscape.
I don't think it would be lighter, SVGs need a rendering tool to read the code and draw the artwork for the vector based images. This has always been slower than just displaying a bmp, jpg, or PNG.
-
Though this also has advantages - not only will they be drawn at an appropriate resolution, they can also be styled & modified by the user. If I'm using Dark Reader and your icons are SVGs using
currentColor
, they'll render with the same color as other text. The best you can do for raster graphics is inverting them.i too love the svg. rest assured.
-
No, SVG files are not HTML.
Please change this post title (currently "today i learned: svg files are literally just html code"), to avoid spreading this incorrect factoid!
I suggest you change it to "today i learned: svg files contain code in an html-like language" or something like that.
XML and HTML have many similarities, because they are both are descendants of SGML. But, as others have noted in this thread, HTML is also not XML. (Except for when it's XHTML...)
Like HTML, SVG also can use CSS, and, in some environments (eg, in browsers, but not in Inkscape) also JavaScript. But, the styles you can specify with CSS in SVG are quite different than those you can specify with CSS in HTML.
Lastly, you can embed SVG in HTML and it will work in (modern) browsers. You cannot embed HTML in SVG, however.
You know how they say that the internet is a series of tubes? We used to think that was just a funny old man. Turns out, it is the literal truth. The internet is made up of SVG files!
-
I don't think it would be lighter, SVGs need a rendering tool to read the code and draw the artwork for the vector based images. This has always been slower than just displaying a bmp, jpg, or PNG.
It's lighter in memory. on android (development) it has been said for a few years now that it's better to use them for most cases, because android apps tend to use a ton of icons and this way they are small, themable, scaleable (the other option is to include multiple versions with diff resolutions), and can even have animations. it can basically save a lot of space.
but of course that will make no difference when the apps are 180 MB, partly because of the same 30 MB native libs being bundled for 4 different CPU architectures, because wasteful the dev didn't bother to produce different APKs for the different kinds of CPUs. and similar project mismanagement things.
-
No, it's XML. It's an ancestor of HTML and, unlike HTML, it can be losslessly converted.
Not quite. XML came several years after HTML! Both are descendants of SGML.
-
i didn't know that, is that the same in xfce??
hard to tell, but you can check it:
find / -type f -name *.svg
maybe also include
-xdev
if you have any external drive that doesn't hold system files. -
Ommigod, these kids
SVG comes XML (a more coherent/simple version of the SGML that is behind HTML), and specifically from a time where people took XML and made it hyper-complicated with a flurry of extensions and specifications (look up "xml namespaces" "xslt" "xml schema").
The most apparent difference between SGML and XML is than in the former you write tags like <br> without a corresponding </br>, and in the latter you have to close them like <br/> (which is shorthand for <br></br>).
So... today you learned that what you learned earlier today was close to truth, but not true
PS: A lot of document formats are undercover/zipped XML (eg. the libre office documents, IIRC microsoft's .xlsx and .docx). This is not dissimilar to how json/yaml are widely used today.
So, my Lemmy app - and I think a lot of Lemmy, renders markdown, so whenever you write "<...>" It disappears for me!
-
No, SVG files are not HTML.
Please change this post title (currently "today i learned: svg files are literally just html code"), to avoid spreading this incorrect factoid!
I suggest you change it to "today i learned: svg files contain code in an html-like language" or something like that.
XML and HTML have many similarities, because they are both are descendants of SGML. But, as others have noted in this thread, HTML is also not XML. (Except for when it's XHTML...)
Like HTML, SVG also can use CSS, and, in some environments (eg, in browsers, but not in Inkscape) also JavaScript. But, the styles you can specify with CSS in SVG are quite different than those you can specify with CSS in HTML.
Lastly, you can embed SVG in HTML and it will work in (modern) browsers. You cannot embed HTML in SVG, however.
I remember when XHTML was supposed to replace HTML. Everything was going to be standardized and web designers would run their HTML code against a validator...it was going to be glorious! And of course it never happened, because demanding that all websites conform to the XHTML standard would've broken a lot of websites.
So, HTML5 ate XHTML's lunch because it was much more forgiving, and...oh yeah, you could watch videos and play games in it, too.
-
I remember when XHTML was supposed to replace HTML. Everything was going to be standardized and web designers would run their HTML code against a validator...it was going to be glorious! And of course it never happened, because demanding that all websites conform to the XHTML standard would've broken a lot of websites.
So, HTML5 ate XHTML's lunch because it was much more forgiving, and...oh yeah, you could watch videos and play games in it, too.
I fucking learned a whole-ass language for nothing back then because I thought it was the future!, fuck you, XHTML!
-
I fucking learned a whole-ass language for nothing back then because I thought it was the future!, fuck you, XHTML!
100% of XHTML will work in HTML5.
-
what the heck!! that is so wild, mind blowing, i know the main difference between raster graphics and vector graphics was the quality but not more, i had no idea svg files actually used html code and pretty much could be modified using only text and amazing code woa!!! this opens up the possibility for so many things on linux i think, for example, on a linux distro, we could modify the desktop environment and make it waaaaay lighter by getting rid of jpg or png icons and just using pure svg on it. svg can be given a lot of attributes like movement, mouse hovering, change color, change anything. and most svg files are still under a megabyte. wow.. please let me know other fun facts about svg or eps files. i really like doing graphic design on linux and inkscape.
Hold on now. If an svg will render as valid html in browsers, does that mean I can use Inkscape as a wysiwyg webpage editor, and just export that to html?
-
Hold on now. If an svg will render as valid html in browsers, does that mean I can use Inkscape as a wysiwyg webpage editor, and just export that to html?
good question, i once made a website mockup on inkscape and it would be interesting if i could just turn that into an html file
-
So, my Lemmy app - and I think a lot of Lemmy, renders markdown, so whenever you write "<...>" It disappears for me!
I tried adding backslashes to escape, it still looks fine on lemmy.ml but your app may be bugged (and possibly vulnerable to xss? can you see the script block after the closed bracket?) <script>alert('you should not see an alert')</script>
-
I tried adding backslashes to escape, it still looks fine on lemmy.ml but your app may be bugged (and possibly vulnerable to xss? can you see the script block after the closed bracket?) <script>alert('you should not see an alert')</script>
It all looks good now
-
I fucking learned a whole-ass language for nothing back then because I thought it was the future!, fuck you, XHTML!
-
I remember when XHTML was supposed to replace HTML. Everything was going to be standardized and web designers would run their HTML code against a validator...it was going to be glorious! And of course it never happened, because demanding that all websites conform to the XHTML standard would've broken a lot of websites.
So, HTML5 ate XHTML's lunch because it was much more forgiving, and...oh yeah, you could watch videos and play games in it, too.
-
It annoys me that you aren't supposed to close input tags. At least browsers tolerate self closing them even if it is out of spec.
Technically it's not browser tolerance but spec tolerance. It's built into the html5 spec to tolerate different tags closing and other things invalid in xml.
This was an important design that grew out of one of the largest failings of xhtml that such failures would make the entire page unrenderable.
-