Save Illustrator for SVG to use in HTML page

When working with the AWS contact form, I had created a graphic in Illustrator. You can see the post here.

With this test form I wanted to have everything in one HTML file this way it’s just one file to upload and update when needed without making sure the other files are there.

To get the image to be embedded, it needs to be a SVG format. Since SVG files are just code I can be embedded in an HTML file. Since I created the logo in Illustrator, I can save it out to a SVG file and embed the logo in the HTML file.

In Illustrator:

To insure the text looks as expected convert any fonts to outline, or you will need to use a common or a web based font.

Note: Illustrator file can’t have any raster images imported into it.

If you created your graphic with layers and gave them web safe names when you save to SVG click ‘More options’ then click the box that says ‘Unused Graphic Styles’ this will add the name of the layer to the graphic pieces, I called one of my layers ‘toyBox’ this is the rounded box at the bottom.

Quick instructions:

Open Illustrator file

Save a copy, depends on what you have to do next you might need to go back to the original.

Name your layers, or separate out areas into layers and give each a name like sky.

Convert text to outlines.

Save as or Export to SVG with these settings: SVG 1.1 or higher; Subsetting None; image location ‘Embed’; I have ‘Preserve Illustrator Editing Capabilities’ unchecked, thinking this could add more code to it, if I will be editing I’ll do it from the original Illustrator file.

You can click on the Code in the save window to pull the code or save and open in a text editor like notepad or a code program like VS code.

You’ll want the info from <svg… to </svg>; you don’t need the XML data above the svg tag,  you’ll add this on its own and not in an image tag ‘<img…’ I also added an ‘id=”logo”’ to this so I could easily add CSS to give it the right size and center it on the page, you can also call out svg in CSS but if you have more than one it will affect all. The CSS to get the size and centered:

#logo {
    width:300px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

If you used layers you can use that ID in your CSS to do things like at animation.

In the ‘Toys & Collectibles’ area I put this CSS in to change the text to pink per char when you hover over:

#ToyTxt .st6:hover {  fill: #f7abf7; }

Related Articles

Video: Din-Din with Augy

Video: Din-Din with Augy

Starting to learn how to do video editing, and to help focus the learning I needed to create some kind of project. I decided that Augy, a betta fish, would be my star, because of his star quality and he’s right here. https://www.youtube.com/watch?v=PHNwRkvYngs Keeping...

read more
Website Contact form using AWS

Website Contact form using AWS

For the next iteration of the HTML form was to set it up to send an email to the web owner using AWS. The purpose behind this is, if you have a HTML site and don’t want to purchase a monthly plan or build and maintain server software. Using AWS for this functionality...

read more
HTML with JavaScript contact form

HTML with JavaScript contact form

Link to the form: https://www.lynnamacher.com/pdf/contactForm_V1.html This is created to be basic test for an AWS contact form test. The full form when filled out will send an email through AWS to the site owner. Instead of creating the normal test form I try to...

read more

Pin It on Pinterest

Share This