r/HTML • u/username95050 • Oct 11 '26
SVG Issues?
SVG isn't CSS , so may I ask here?
Learning svg, but I don't want to draw my own images, I want to use pre-drawn images and maps and make things clickable. How do I do that?
5
Upvotes
1
u/brisray Oct 11 '26
Using a program like the free Inkscape you can import images, position them and use Inkscape's Bezier Curve and Straight Line tools to create the clickable areas. The shapes needs to be filled for the link to work, but the shape's alpha channel can be set to transparent by going to Filters > Fill and Transparency > Channel Transparency.
I've put an example on this web page.
1
u/MineDesperate8982 Oct 11 '26
If you're talking about real-world map, you can look up, or draw and generate a geojson file, convert it to svg, then, assignd to each region path a class or id. Then you play however you want with it.
https://jsfiddle.net/v81msgxo/
In the given example, I had a GeoJson for Romania's counties. I used an online tool to merge the counties in to regions, downloaded the geojson, then I converted it to svg using an online tool I just googled.
I then assigned a class to every region to control what happens on hover and what-not and pasted in a simple onclick script. You can just use Java to make it in the script section (if the user clicks x region do y).
1
u/aunderroad Oct 11 '26
Here are some great tutorials about SVGs:
https://svgpocketguide.com/
https://svg-tutorial.com/
https://www.joshwcomeau.com/svg/friendly-introduction-to-svg/
Once you get the SVGs basics down, check out this tutorial by freecodecamp:
How to Make a Clickable SVG Map With HTML and CSS
Here is a good link for SVG maps:
https://www.amcharts.com/svg-maps/
1
u/Weekly_Ferret_meal Oct 11 '26
r/svg
3
u/DirtAndGrass Oct 11 '26
> make things clickable
The same way as html
0
u/[deleted] Oct 11 '26
[deleted] — view deleted comment