SVG

Learn about working with SVG to use XML and JavaScript to create web graphics that respond to user actions with sophisticated effects such as highlighting, tool tips, audio, and animation.

Adobe Illustrator deeplink

Try it in the app
Apply SVG filters in a few simple steps.

About SVG

SVG is a vector format that describes images as shapes, paths, text, and filter effects. The resulting files are compact and provide high-quality graphics on the web, in print, and even on resource-constrained, handheld devices, unlike GIF, JPEG, WBMP, and PNG, which are bulky. Users can magnify their view of an SVG image on‑screen without sacrificing sharpness, detail, or clarity. In addition, SVG provides superior support for text and colors, which ensures that users see images as they appear on your Illustrator artboard.

The SVG format is entirely XML-based and offers many advantages to developers and users alike. 

You can save artwork in SVG format using the Save, Save As, Save A Copy, or Save For Web & Devices commands. To access the complete set of SVG export options, use the Save, Save As, or Save A Copy command. The Save For Web & Devices command provides a subset of SVG export options which are applicable to web-oriented work.

Apply SVG effects

You can use SVG effects (filters) to add graphic properties like drop shadows to your artwork. SVG effects differ from their bitmap counterparts in that they are XML-based and resolution-independent. An SVG effect is nothing more than a series of XML properties that describe various mathematical operations. The resulting effect is rendered to the target object instead of the source graphic.

Illustrator provides a default set of SVG effects. You can apply a default effect directly or edit its XML code to customize it. You can also create new SVG effects.

Note:

To modify Illustrator’s default SVG filters, edit the Adobe SVG Filters.svg file in the following location using a text editor:

  • macOS: ~/Library/Application Support/Adobe/Adobe Illustrator <version>/<locale>
  • Windows: C:\Users\<username>\AppData\Roaming\Adobe\Adobe Illustrator <version> Settings\<locale>\x64

You can modify existing filter definitions, delete them, and add new ones.

Apply a default effect

  1. Select an object or group (or a layer in the Layers panel).

  2. Go to Effect > SVG Filters > Apply SVG Filter.

Apply a custom effect

  1. Select an object or group (or a layer in the Layers panel).

  2. Go to Effect > SVG Filters > Apply SVG Filter.

  3. In the dialog box, select an effect and then select Edit SVG Filter   . Edit the default code and select OK.

Create and apply a new effect

  1. Select an object or group (or a layer in the Layers panel).

  2. Go to Effect > SVG Filters > Apply SVG Filter.

  3. In the dialog box, select New SVG Filter   . Enter the new code and select OK.

When you apply an SVG filter effect, Illustrator displays a rasterized version of the effect on the artboard. You can control the resolution of this preview image by modifying the document's rasterization resolution setting.

Note:

An SVG effect must be the last effect when an object uses multiple effects. In other words, it must appear at the bottom of the Appearance panel (just above the Transparency entry). If other effects follow an SVG effect, the SVG output will consist of a raster object.

Import effects from an SVG file

  1. Select Effect > SVG Filter > Import SVG Filter.

  2. Select the SVG file you want to import effects from and select Open.

SVG Interactivity panel overview

The SVG Interactivity panel lets you see all the events and JavaScript files associated with the current file.
You can use the SVG Interactivity panel (Window > SVG Interactivity) to add interactivity to your artwork when it is exported for viewing in a web browser. For example, by creating an event that triggers a JavaScript command, you can quickly create movement on a web page when the user performs an action, such as moving a mouse cursor over an object.

Delete an event from the SVG Interactivity panel

You can use SVG Interactivity panel to delete one or all events.

To delete one event

  • Select the event and select Remove Selected Entry   .

To delete all events

  • Select Clear Events from the panel menu  

List, add, or remove events linked to a file

Select the Link JavaScript files   and select Add to add additional JavaScript files, whereas to remove the selected JavaScript entry, select Remove.

Add SVG Interactivity to artwork

  1. In the SVG Interactivity panel, select an Event. (See SVG events.)

  2. Enter the corresponding JavaScript, and press Enter.

SVG events

onfocusin

Triggers the action when the element receives focus, such as selection by the pointer.

onfocusout

Triggers the action when the element loses focus (often when another element receives focus).

onactivate

Triggers the action with a mouse click or keypress, depending upon the SVG element.

onmousedown

Triggers the action when the mouse button is pressed down over an element.

onmouseup

Triggers the action when the mouse button is released over an element.

onclick

Triggers the action when the mouse is clicked over an element.

onmouseover

Triggers the action when the pointer is moved onto an element.

onmousemove

Triggers the action while the pointer is over an element.

onmouseout

Triggers the action when the pointer is moved away from an element.

onkeydown

Triggers the action when a key is pressed down.

onkeypress

Triggers the action while a key is pressed down.

onkeyup

Triggers the action when a key is released.

onload

Triggers the action after the SVG document has been completely parsed by the browser. Use this event to call one-time-only initialization functions.

onerror

Triggers the action when an element does not load properly or another error occurs.

onabort

Triggers the action when the page loading is stopped before the element is completely loaded.

onunload

Triggers the action when the SVG document is removed from a window or frame.

onzoom

Triggers the action when the zoom level is changed for the document.

onresize

Triggers the action when the document view is resized.

onscroll

Triggers the action when the document view is scrolled or panned.

Tips for creating SVG files

  • Use layers to add structure to an SVG file. Each layer is converted to a group (<g>) element when you save artwork in SVG format. (For example, a layer named Button1 becomes <g id="Button1_ver3.0"> in the SVG file.) Nested layers become SVG nested groups, and hidden layers are preserved with the display="none" SVG styling property.

  • If you want objects on different layers to appear transparent, adjust the opacity of each object instead of each layer.

  • Raster data isn't scalable in the SVG Viewer and cannot be edited like other SVG elements. You can just avoid creating artwork that will be rasterized in the SVG file. Use SVG effects to add graphic effects without causing rasterization.

  • Use symbols and simplify the paths in your artwork to improve SVG performance. Also, avoid using brushes that produce a lot of path data, such as the Charcoal, Fire Ash, and Scroll Pen, if performance is a high priority.

  • Use slices, image maps, and scripts to add web links to an SVG file.

  • A scripting language, such as JavaScript, opens unlimited functionality to an SVG file. Pointer and keyboard movements can invoke scripting functions such as rollover effects.

Web-optimized SVG export options

A new SVG Export (File > Export > Export As > SVG) option is available. The new workflow allows you to generate standardized, web-optimized SVG files for your web and screen design projects. For more information, see SVG export options.

More like this

Have a question or an idea?

Ask the Community

If you have a question to ask or an idea to share, come and participate in Adobe Illustrator Community. We would love to hear from you and see your creations.

Get help faster and easier

New user?