Hubbry Logo
SVGSVGMain
Open search
SVG
Community hub
SVG
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Contribute something
SVG
SVG
from Wikipedia
SVG
Filename extensions.svg, .svgz
Internet media typeimage/svg+xml[1][2]
Uniform Type Identifier (UTI)public.svg-image
Developed byW3C
Initial release4 September 2001 (24 years ago) (2001-09-04)
Latest release
1.1 (Second Edition)
16 August 2011; 14 years ago (2011-08-16)
Type of formatVector graphics
Extended fromXML
StandardW3C SVG
Open format?Yes
Websitewww.w3.org/Graphics/SVG/

Scalable Vector Graphics (SVG) is an XML-based vector graphics format for defining two-dimensional graphics, having support for interactivity and animation. The SVG specification is an open standard developed by the World Wide Web Consortium since 1999.

SVG images are defined in a vector graphics format and stored in XML text files. SVG images can thus be scaled in size without loss of quality, and SVG files can be searched, indexed, scripted, and compressed. The XML text files can be created and edited with text editors or vector graphics editors, and are rendered by most web browsers. SVG can include JavaScript, potentially leading to cross-site scripting.

History

[edit]

SVG has been in development within the World Wide Web Consortium (W3C) since 1999 after six competing proposals for vector graphics languages had been submitted to the consortium during 1998 (see below).[3]

The early SVG Working Group decided not to develop any of the commercial submissions, but to create a new markup language that was informed by but not really based on any of them.[3]

SVG was developed by the W3C SVG Working Group starting in 1998, after six competing vector graphics submissions were received that year:

The working group was chaired at the time by Chris Lilley of the W3C.

Early adoption was limited due to lack of support in older versions of Internet Explorer. However, as of 2011, all major desktop browsers began to support SVG. Native browser support offers various advantages, such as not requiring plugins, allowing SVG to be mixed with other content, and improving rendering and scripting reliability. Mobile support for SVG exists in various forms, with different devices and browsers supporting SVG Tiny 1.1 or 1.2. SVG can be produced using vector graphics editors and rendered into raster formats. In web-based applications, Inline SVG allows embedding SVG content within HTML documents.

The SVG specification was updated to version 1.1 in 2011. Scalable Vector Graphics 2 became a W3C Candidate Recommendation on 15 September 2016. SVG 2 incorporates several new features in addition to those of SVG 1.1 and SVG Tiny 1.2.[9]

Version 1.x

[edit]
  • SVG 1.0 became a W3C Recommendation on 4 September 2001.[10]
  • SVG 1.1 became a W3C Recommendation on 14 January 2003.[11] The SVG 1.1 specification is modularized in order to allow subsets to be defined as profiles. Apart from this, there is very little difference between SVG 1.1 and SVG 1.0.
    • SVG Tiny and SVG Basic (the Mobile SVG Profiles) became W3C Recommendations on 14 January 2003. These are described as profiles of SVG 1.1.[12]
  • SVG Tiny 1.2 became a W3C Recommendation on 22 December 2008.[13] It was initially drafted as a profile of the planned SVG Full 1.2 (which has since been dropped in favor of SVG 2),[14] but was later refactored as a standalone specification. It is generally poorly supported.
  • SVG 1.1 Second Edition, which includes all the errata and clarifications, but no new features to the original SVG 1.1 was released on 16 August 2011.[15]
  • SVG Tiny 1.2 Portable/Secure, a more secure subset of the SVG Tiny 1.2 profile introduced as an IETF draft standard on 29 July 2020.[16] Also known as SVG Tiny P/S. SVG Tiny 1.2 Portable/Secure is a requirement of the BIMI draft standard.[17]

Version 2

[edit]

SVG 2 removes or deprecates some features of SVG 1.1 and incorporates new features from HTML5 and Web Open Font Format (WOFF):[18]

  • For example, SVG 2 removes several font elements such as glyph and altGlyph (replaced by the WOFF).
  • The xml:space attribute is deprecated in favor of CSS.
  • HTML5 features such as translate and data-* attributes have been added.
  • Text handling features from SVG Tiny 1.2 are annotated as to be included, but not yet formalized in text.[19] Some other 1.2 features are cherry picked in,[18] but SVG 2 is not a superset of SVG tiny 1.2 in general.

SVG 2 reached the Candidate Recommendation stage on 15 September 2016,[20] and revised versions were published on 7 August 2018 and 4 October 2018.[21] The latest draft was released on 14 September 2025.[22]

Features

[edit]
This image illustrates the difference between bitmap and vector images. The bitmap image is composed of a fixed set of pixels, while the vector image is composed of a fixed set of shapes. In the picture, scaling the bitmap reveals the pixels while scaling the vector image preserves the shapes.

SVG supports interactivity, animation, and rich graphical capabilities, making it suitable for both web and print applications. SVG images can be compressed with the gzip algorithm, resulting in SVGZ files that are typically 20–50% smaller than the original. SVG also supports metadata, enabling better indexing, searching, and retrieval of SVG content.

SVG allows three types of graphic objects: vector graphic shapes (such as paths consisting of straight lines and curves), bitmap images, and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects. The feature set includes nested transformations, clipping paths, alpha masks, filter effects and template objects. SVG drawings can be interactive and can include animation, defined in the SVG XML elements or via scripting that accesses the SVG Document Object Model (DOM).

SVG uses CSS for styling and JavaScript for scripting. Text, including internationalization and localization, appearing in plain text within the SVG DOM, enhances the accessibility of SVG graphics.[15]

Printing

[edit]

Though the SVG Specification primarily focuses on vector graphics markup language, its design includes the basic capabilities of a page description language like Adobe's PDF. It contains provisions for rich graphics, and is compatible with CSS for styling purposes. SVG has the information needed to place each glyph and image in a chosen location on a printed page.[23]

Scripting and animation

[edit]

SVG drawings can be dynamic and interactive. Time-based modifications to the elements can be described in SMIL, or can be programmed in a scripting language (e.g. JavaScript). The W3C explicitly recommends SMIL as the standard for animation in SVG.[24]

A rich set of event handlers such as "onmouseover" and "onclick" can be assigned to any SVG graphical object to apply actions and events.

Mobile profiles

[edit]

Because of industry demand, two mobile profiles were introduced with SVG 1.1: SVG Tiny (SVGT) and SVG Basic (SVGB).

These are subsets of the full SVG standard, mainly intended for user agents with limited capabilities. In particular, SVG Tiny was defined for highly restricted mobile devices such as cellphones; it does not support styling or scripting.[25] SVG Basic was defined for higher-level mobile devices, such as smartphones.

In 2003, the 3GPP, an international telecommunications standards group, adopted SVG Tiny as the mandatory vector graphics media format for next-generation phones. SVGT is the required vector graphics format and support of SVGB is optional for Multimedia Messaging Service (MMS) and Packet-switched Streaming Service.[26][27][28] It was later[when?] added as required format for vector graphics in 3GPP IP Multimedia Subsystem (IMS).[29]

Neither mobile profile includes support for the full Document Object Model (DOM), while only SVG Basic has optional support for scripting, but because they are fully compatible subsets of the full standard, most SVG graphics can still be rendered by devices which only support the mobile profiles.[30]

SVGT 1.2 adds a microDOM (μDOM), styling and scripting.[25] SVGT 1.2 also includes some features not found in SVG 1.1, including non-scaling strokes, which are supported by some SVG 1.1 implementations, such as Opera, Firefox, and WebKit. As shared code bases between desktop and mobile browsers increased, the use of SVG 1.1 over SVGT 1.2 also increased.

Compression

[edit]

SVG images, being XML, contain many repeated fragments of text, so they are well suited for lossless data compression algorithms. When an SVG image has been compressed with the gzip algorithm, it is referred to as an "SVGZ" image and uses the corresponding .svgz filename extension. Conforming SVG 1.1 viewers will display compressed images.[31] An SVGZ file is typically 20 to 50 percent of the original size.[32] W3C provides SVGZ files to test for conformance.[33]

Design

[edit]

The SVG 1.1 specification defines 14 functional areas or feature sets:[11]

Paths
Simple or compound shape outlines are drawn with curved or straight lines that can be filled in, outlined, or used as a clipping path. Paths have a compact coding.
For example, M (for "move to") precedes initial numeric x and y coordinates, and L (for "line to") precedes a point to which a line should be drawn. Further command letters (C, S, Q, T, and A) precede data that is used to draw various Bézier and elliptical curves. Z is used to close a path.
In all cases, absolute coordinates follow capital letter commands and relative coordinates are used after the equivalent lower-case letters.[34]
Basic shapes
Straight-line paths and paths made up of a series of connected straight-line segments (polylines), as well as closed polygons, circles, and ellipses can be drawn. Rectangles and round-cornered rectangles are also standard elements.[35]
Text
Unicode character text included in an SVG file is expressed as XML character data. Many visual effects are possible, and the SVG specification automatically handles bidirectional text (for composing a combination of English and Arabic text, for example), vertical text (as Chinese or Japanese may be written) and characters along a curved path (such as the text around the edge of the Great Seal of the United States).[36]
Painting
SVG shapes can be filled and outlined (painted with a color, a gradient, or a pattern). Fills may be opaque, or have any degree of transparency.
"Markers" are line-end features, such as arrowheads, or symbols that can appear at the vertices of a polygon.[37]
Color
Colors can be applied to all visible SVG elements, either directly or via fill, stroke, and other properties. Colors are specified in the same way as in CSS2, i.e. using names like black or blue, in hexadecimal such as #2f0 or #22ff00, in decimal like rgb(255,255,127), or as percentages of the form rgb(100%,100%,50%).[38]
Gradients and patterns
SVG shapes can be filled or outlined with solid colors as above, or with color gradients or with repeating patterns. Color gradients can be linear or radial (circular), and can involve any number of colors as well as repeats. Opacity gradients can also be specified. Patterns are based on predefined raster or vector graphic objects, which can be repeated in x and y directions. Gradients and patterns can be animated and scripted.[39]
Since 2008, there has been discussion[40][41] among professional users of SVG that either gradient meshes or preferably diffusion curves could usefully be added to the SVG specification. It is said that a "simple representation [using diffusion curves] is capable of representing even very subtle shading effects"[42] and that "Diffusion curve images are comparable both in quality and coding efficiency with gradient meshes, but are simpler to create (according to several artists who have used both tools), and can be captured from bitmaps fully automatically."[43] The current draft of SVG 2 includes gradient meshes.[44]
Clipping, masking and compositing
Graphic elements, including text, paths, basic shapes and combinations of these, can be used as outlines to define both inside and outside regions that can be painted (with colors, gradients and patterns) independently. Fully opaque clipping paths and semi-transparent masks are composited together to calculate the color and opacity of every pixel of the final image, using alpha blending.[45]
Filter effects[46]
A filter effect consists of a series of graphics operations that are applied to a given source vector graphic to produce a modified bitmapped result.
Interactivity
SVG images can interact with users in many ways. In addition to hyperlinks as mentioned below, any part of an SVG image can be made receptive to user interface events such as changes in focus, mouse clicks, scrolling or zooming the image and other pointer, keyboard and document events. Event handlers may start, stop or alter animations as well as trigger scripts in response to such events.[47]
Linking
SVG images can contain hyperlinks to other documents, using XLink. Through the use of the <view> element or a fragment identifier, URLs can link to SVG files that change the visible area of the document. This allows for creating specific view states that are used to zoom in/out of a specific area or to limit the view to a specific element. This is helpful when creating sprites. XLink support in combination with the <use> element also allow linking to and re-using internal and external elements. This allows coders to do more with less markup and makes for cleaner code.[48]
Scripting
All aspects of an SVG document can be accessed and manipulated using scripts in a similar way to HTML. The default scripting language is JavaScript and there are defined Document Object Model (DOM) objects for every SVG element and attribute. Scripts are enclosed in <script> elements. They can run in response to pointer events, keyboard events and document events as required.[49]
Animation
SVG content can be animated using the built-in animation elements such as <animate>, <animateMotion> and <animateColor>. Content can be animated by manipulating the DOM using ECMAScript and the scripting language's built-in timers. SVG animation has been designed to be compatible with current and future versions of Synchronized Multimedia Integration Language (SMIL). Animations can be continuous, they can loop and repeat, and they can respond to user events, as mentioned above.[50]
Fonts
As with HTML and CSS, text in SVG may reference external font files, such as system fonts. If the required font files do not exist on the machine where the SVG file is rendered, the text may not appear as intended. To overcome this limitation, text can be displayed in an SVG font, where the required glyphs are defined in SVG as a font that is then referenced from the <text> element.[51]
Metadata
In accord with the W3C's Semantic Web initiative, SVG allows authors to provide metadata about SVG content. The main facility is the <metadata> element, where the document can be described using Dublin Core metadata properties (e.g. title, creator/author, subject, description, etc.). Other metadata schemas may also be used. In addition, SVG defines <title> and <desc> elements where authors may also provide plain-text descriptive material within an SVG image to help indexing, searching and retrieval by a number of means.[52]

An SVG document can define components including shapes, gradients etc., and use them repeatedly. SVG images can also contain raster graphics, such as PNG and JPEG images, and further SVG images.

This code will produce the colored shapes shown in the image, excluding the grid and labels:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="391" height="391" viewBox="-70.5 -70.5 391 391" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect fill="#fff" stroke="#000" x="-70" y="-70" width="390" height="390"/>
<g opacity="0.8">
	<rect x="25" y="25" width="200" height="200" fill="lime" stroke-width="4" stroke="pink" />
	<circle cx="125" cy="125" r="75" fill="orange" />
	<polyline points="50,150 50,200 200,200 200,100" stroke="red" stroke-width="4" fill="none" />
	<line x1="50" y1="50" x2="200" y2="200" stroke="blue" stroke-width="4" />
</g>
</svg>

Implementation

[edit]

The use of SVG on the web was limited by the lack of support in older versions of Internet Explorer (IE). Many websites that serve SVG images also provide the images in a raster format, either automatically by HTTP content negotiation or by allowing the user directly to choose the file.

Web browsers

[edit]

Konqueror was the first browser to support SVG in release version 3.2 in February 2004.[53] As of 2011, all major desktop browsers, and many minor ones, have some level of SVG support. Other browsers' implementations are not yet complete; see comparison of layout engines for further details.

Some earlier versions of Firefox (e.g. versions between 1.5 and 3.6[54]), as well as a few other, now outdated, web browsers capable of displaying SVG graphics, needed them embedded in <object> or <iframe> elements to display them integrated as parts of an HTML webpage instead of using the standard way of integrating images with <img>.[55] However, SVG images may be included in XHTML pages using XML namespaces.[56]

Tim Berners-Lee, the inventor of the World Wide Web, was critical of early versions of Internet Explorer for its failure to support SVG.[57]

There are several advantages to native and full support: plugins are not needed, SVG can be freely mixed with other content in a single document, and rendering and scripting become considerably more reliable.[67]

Mobile devices

[edit]

Support for SVG may be limited to SVGT on older or more limited smart phones or may be primarily limited by their respective operating system. Adobe Flash Lite has optionally supported SVG Tiny since version 1.1. At the SVG Open 2005 conference, Sun demonstrated a mobile implementation of SVG Tiny 1.1 for the Connected Limited Device Configuration (CLDC) platform.[68]

Mobiles that use Opera Mobile, as well as the iPhone's built in browser, also include SVG support. However, even though it used the WebKit engine, the Android built-in browser did not support SVG prior to v3.0 (Honeycomb).[69] Prior to v3.0, Firefox Mobile 4.0b2 (beta) for Android was the first browser running under Android to support SVG by default.[70]

The level of SVG Tiny support available varies from mobile to mobile, depending on the SVG engine installed. Many newer mobile products support additional features beyond SVG Tiny 1.1, like gradient and opacity; this is sometimes referred to as "SVGT 1.1+", though there is no such standard.

RIM's BlackBerry has built-in support for SVG Tiny 1.1 since version 5.0.[71] Support continues for WebKit-based BlackBerry Torch browser in OS 6 and 7.[72]

Nokia's S60 platform has built-in support for SVG. For example, icons are generally rendered using the platform's SVG engine. Nokia has also led the JSR 226: Scalable 2D Vector Graphics API expert group that defines Java ME API for SVG presentation and manipulation. This API has been implemented in S60 Platform 3rd Edition Feature Pack 1 and onward.[73] Some Series 40 phones also support SVG (such as Nokia 6280).[74]

Most Sony Ericsson phones beginning with K700 (by release date) support SVG Tiny 1.1. Phones beginning with K750 also support such features as opacity and gradients. Phones with Sony Ericsson Java Platform-8 have support for JSR 226.[citation needed]

Windows Phone has supported SVG since version 7.5.

SVG is also supported on various mobile devices from Motorola, Samsung, LG, and Siemens mobile/BenQ-Siemens. eSVG, an SVG rendering library mainly written for embedded devices, is available on some mobile platforms.[75][76]

Authoring

[edit]
In addition to manually entering code and using vector graphics editors, users can use spreadsheet programs' concatenate function to join numeric cell values and text strings in series, to generate full SVG declarations.

SVG images can be hand coded or produced by the use of a vector graphics editor, such as Inkscape, Adobe Illustrator, Adobe Animate, or CorelDRAW, and rendered to common raster image formats such as PNG using the same software. Additionally, editors like Inkscape and Boxy SVG provide tools to trace raster images to Bézier curves typically using image tracing back-ends like potrace,[77] autotrace, and imagetracerjs.

Software can be programmed to render SVG images by using a library such as librsvg used by GNOME since 2000, Batik and ThorVG (Thor Vector Graphics) since 2020 for lightweight systems. SVG images can also be rendered to any desired popular image format by using ImageMagick, a free command-line utility (which also uses librsvg under the hood).

For web-based applications, the mode of usage termed Inline SVG allows SVG content to be embedded within an HTML document using an <svg> tag. Its graphical capabilities can then be employed to create sophisticated user interfaces as the SVG and HTML share context, event handling, and CSS.

Other uses for SVG include embedding for use in word processing (e.g. with LibreOffice) and desktop publishing (e.g. Scribus), plotting graphs (e.g. gnuplot), and importing paths (e.g. for use in GIMP or Blender). The application services Microsoft 365 and Microsoft Office 2019 offer support for exporting,[78] importing and editing SVG images. The Uniform Type Identifier for SVG used by Apple is public.svg-image and conforms to public.image and public.xml.

Security

[edit]

As a document format, similar to HTML documents, SVG can host scripts or CSS. This is an issue when an attacker can upload a SVG file to a website, such as a profile picture, and the file is treated as a normal picture but contains malicious content.[79] For instance, if an SVG file is deployed as a CSS background image, or a logo on some website, or in some image gallery, then when the image is loaded in a browser it activates a script or other content. This could lock up the browser (the Billion laughs attack), but could also lead to HTML injection and cross-site scripting attacks. The W3C therefore stipulate certain requirements when SVG is simply used for images: SVG Security.[80]

The W3C says that Inline SVG (an SVG file loaded natively on a website) is considered less of a security risk because the content is part of a greater document, and so scripting and CSS would not be unexpected.[80]

[edit]

The MPEG-4 Part 20 standard – Lightweight Application Scene Representation (LASeR) and Simple Aggregation Format (SAF) is based on SVG Tiny.[81] It was developed by MPEG (ISO/IEC JTC 1/SC29/WG11) and published as ISO/IEC 14496-20:2006.[82] SVG capabilities are enhanced in MPEG-4 Part 20 with key features for mobile services, such as dynamic updates, binary encoding, state-of-art font representation.[83] SVG was also accommodated in MPEG-4 Part 11, in the Extensible MPEG-4 Textual (XMT) format – a textual representation of the MPEG-4 multimedia content using XML.[84]

See also

[edit]

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Scalable Vector Graphics (SVG) is an XML-based markup language for describing two-dimensional vector and mixed vector/raster graphics in both static and animated forms. Developed by the World Wide Web Consortium (W3C), SVG enables the creation of scalable images that retain clarity and detail at any resolution without pixelation, distinguishing it from raster formats like PNG or JPEG. The format originated from the W3C's 1996 requirements document for scalable vector graphics to address the limitations of bitmap images on the web, with proposals submitted in 1998. The first public working draft appeared in 1999, leading to the SVG 1.0 Recommendation in September 2001 and SVG 1.1 in January 2003. A second edition of SVG 1.1 was published in August 2011 to incorporate errata and clarifications. SVG 2, which extends SVG 1.1 with enhancements for usability, precision, and new features like improved text handling and CSS integration, reached Candidate Recommendation status in October 2018 and remains under active development as of 2025. Key features of SVG include support for basic shapes, paths, text, gradients, patterns, clipping, masking, and filters for visual effects. It integrates seamlessly with and XML documents, allowing SVG elements to be embedded inline or referenced externally, and can be styled using CSS while enabling dynamic modifications via . Animations are possible through declarative SMIL syntax or scripting, and the format supports accessibility features like attributes for screen readers. SVG is natively supported by all modern web browsers, including Chrome, , , and Edge, with full basic support in major browsers beginning in and across all major browsers by 2011. Widely used for icons, logos, diagrams, and data visualizations on the web, SVG's text-based nature also facilitates searchability, compression, and programmatic generation.

Introduction

Definition and Purpose

Scalable Vector Graphics (SVG) is an XML-based for describing two-dimensional , which can include mixed vector and raster elements, and supports and capabilities. It allows for the creation of graphics that are stylable with CSS and scriptable with languages like , enabling dynamic content. As an open standard developed by the (W3C), SVG facilitates embedding directly into documents, making it integral to web-based applications and documents. The primary purpose of SVG is to produce scalable icons, logos, charts, and diagrams that maintain sharpness and clarity at any resolution or zoom level, without , due to its vector nature. This scalability supports its use in diverse contexts, from web interfaces to high-resolution printing. Additionally, SVG's text-based format promotes by allowing screen readers to interpret descriptive elements and benefits (SEO) through indexable text content within the graphics. SVG was first established as a W3C Recommendation in September 2001 with version 1.0, marking it as a foundational for on the web. Common use cases include data visualization for interactive charts, elements like buttons and icons, and print-ready illustrations that adapt seamlessly across digital and physical media. Subsequent evolution, such as SVG 2, has enhanced these features for broader interoperability.

Key Advantages

Scalable Vector Graphics (SVG) offers resolution independence, allowing images to scale infinitely without loss of quality, which makes it particularly suitable for and high-DPI displays such as screens. Unlike raster formats like or , which pixelate when enlarged, SVG maintains crisp edges through its vector-based definitions, ensuring consistent rendering across devices and zoom levels. SVG files achieve smaller sizes for complex graphics compared to equivalent raster images because they use mathematical descriptions of shapes, paths, and colors rather than storing . This parametric approach—defining elements via coordinates and formulas—results in compact representations that compress efficiently, reducing bandwidth needs while preserving detail for intricate diagrams or icons. As a text-based XML format, SVG is inherently editable with standard text editors or integrated development environments, facilitating direct modifications without specialized software. This structure also enables programmatic manipulation through languages like , allowing dynamic updates to elements at runtime, and supports version control systems such as due to its plain-text nature. SVG provides built-in accessibility features, including support for WAI-ARIA attributes that convey semantic roles, states, and descriptions to assistive technologies like screen readers. For instance, attributes such as aria-label and role can describe graphical elements, making charts or icons interpretable for users with disabilities, while the text-based format enhances searchability by allowing content to be indexed by search engines. The format natively supports interactivity, such as hover effects via CSS pseudo-classes and animations through integrated SMIL or CSS transitions, enabling responsive behaviors without external plugins. This built-in capability allows developers to create engaging user experiences, like tooltips on or smooth scaling transitions, directly within the SVG document.

History

Early Development and SVG 1.0

The development of Scalable Vector Graphics (SVG) originated in the mid-1990s as part of the Consortium's (W3C) efforts to establish an for on the web, driven by the need for scalable, resolution-independent imagery amid the limitations of raster formats and proprietary technologies like Flash. In 1996, W3C chair Chris Lilley published requirements for scalable graphics, emphasizing resizability for varying display densities, improved print quality, and enhanced interactivity to address the growing demand for dynamic without relying on closed formats. This initiative gained momentum in 1998 when the W3C chartered the SVG Working Group, involving key contributors from industry leaders including Adobe Systems, , , , and others, to create a unified XML-based language that combined elements from competing proposals such as Adobe's Precision Graphics Markup Language (PGML) and Microsoft's (VML). The SVG Working Group aimed to provide an open alternative to proprietary vector solutions, focusing on web integration, accessibility, and extensibility through XML syntax. The first public working draft of SVG was released on February 11, 1999, outlining a specification for two-dimensional vector and mixed vector/raster graphics with support for basic shapes, paths, text, gradients, and styling via CSS. Following iterative reviews and last-call drafts, including the eighth working draft on March 3, 2000, SVG advanced to Candidate Recommendation status on August 2, 2000, marking a significant milestone toward standardization. SVG 1.0 was formally published as a W3C Recommendation on September 4, 2001, establishing foundational features such as a for precise positioning, definitions for scalable rendering across devices, and seamless integration with for embedding graphics in web documents. These elements enabled developers to create resolution-independent illustrations, diagrams, and interfaces without , while supporting hyperlinking and basic . Key goals included promoting through open standards and fostering adoption in web authoring tools, though early implementations relied on plugins like Adobe's SVG Viewer released in late 2001. Despite these advancements, SVG 1.0 faced significant early adoption challenges due to limited native browser support; for instance, while provided partial rendering by 2003, required external viewers until version 9 in 2011, delaying widespread use until the mid-2000s. This reliance on plugins and inconsistent implementations across platforms initially hindered SVG's penetration in , though it laid the groundwork for future modular profiles in subsequent versions.

SVG 1.1 Standardization

SVG 1.1 was published as a W3C Recommendation on January 14, 2003, marking a significant maturation of the Scalable Vector Graphics standard from its initial 1.0 version. This release focused on stabilizing and expanding the core specification to better support diverse implementation needs while preserving foundational capabilities. A second edition followed on August 16, 2011, primarily to incorporate errata corrections and clarifications without introducing new features. Key enhancements in SVG 1.1 included full support for CSS styling, allowing developers to apply presentation attributes more flexibly across elements. It also provided robust DOM manipulation interfaces for dynamic content modification and integrated animation capabilities through SMIL, enabling declarative timing and synchronization of visual effects. Scripting interfaces were refined to facilitate JavaScript interactions, enhancing interactivity within SVG documents. Additionally, the specification defined over 100 elements, ranging from basic shapes and paths to advanced features like filters and gradients, while ensuring backward compatibility with SVG 1.0 content. To address varying device constraints, SVG 1.1 introduced modularization, dividing the language into profiles such as SVG Tiny for resource-limited mobile devices, SVG Basic for intermediate capabilities, and SVG Full for comprehensive desktop support. This approach allowed tailored implementations without compromising the core standard's integrity. Adoption accelerated with native browser integration, notably in 1.5 released in November 2005, which provided broad SVG rendering support. followed with partial SVG support in in March 2011, broadening accessibility. These milestones contributed to SVG's growth in web applications, particularly for scalable maps and interactive infographics, where its vector precision and dynamic features proved advantageous.

SVG 2 and Ongoing Evolution

The development of SVG 2 began with its first Working Draft published by the W3C on 28 August 2012, building directly on the SVG 1.1 Second Edition to address usability gaps and incorporate community feedback. As of November 16, 2025, the specification remains in Editor's Draft status, with ongoing refinements but no advancement to full W3C Recommendation due to dependencies on broader participation and implementation testing. Some proposed features, such as patterns and direct of elements like <canvas>, <video>, and <audio> without <foreignObject>, have been removed due to lack of interest in implementation. SVG 2 introduces several key enhancements to streamline authoring and rendering. Native support for CSS transforms allows the transform attribute to apply to any element, including the root <svg>, treating it as a presentation attribute compatible with CSS Transforms Module Level 1 for consistent 2D manipulations. This feature is supported in Chrome 137 and later (as of May 2025). Text-on-path functionality improves by permitting the <textPath> element to directly reference path data via a path attribute, simplifying curve-based text layout without external <path> dependencies. Overflow handling is refined to support scrollbars via overflow: scroll on <svg> elements, removing the default overflow: hidden behavior for better viewport control in embedded contexts. Animation capabilities shift away from the deprecated SMIL (Synchronized Multimedia Integration Language) module, which is no longer part of SVG 2, toward integration with CSS Animations and Web Animations API for more performant, scriptable effects aligned with modern web standards. SVG 2 facilitates deeper ties with HTML5 technologies, though embedding HTML content still requires <foreignObject>. Browser implementations remain partial, with features like enhanced transforms available in recent versions of Chrome (137+), though full interoperability lags behind due to the draft status. The W3C SVG Working Group continues iterative updates, with goals for Proposed Recommendation status hinging on increased testing and adoption, potentially targeting completion around 2026 amid calls for renewed focus on specification maturity. Accessibility receives targeted improvements, including native support for tabindex to enable keyboard navigation and attributes like aria-label and role for semantic mapping of graphics to screen readers. Better focus indicators are mandated through user-agent stylesheets that render visible outlines on interactive elements, ensuring compliance with WCAG guidelines for perceivable navigation in vector content.

Core Design Principles

XML-Based Syntax

Scalable Vector Graphics (SVG) is defined as an XML-based language for describing two-dimensional , adhering to the XML 1.0 specification for syntax and structure. As such, SVG documents must be well-formed XML, utilizing the SVG identified by the URI http://www.w3.org/2000/svg to ensure proper element and attribute recognition in XML parsers. This is declared using the xmlns attribute on the , such as xmlns="http://www.w3.org/2000/svg", in compliance with the Namespaces in XML recommendation. The foundational structure of an SVG document centers on the <svg> root element, which establishes the canvas for graphics content. Key attributes of the <svg> element include width and height, which specify the intrinsic dimensions of the viewport—defaults to auto or 100% for embedded contexts—and viewBox, which defines a coordinate system for scaling content independently of resolution. The viewBox attribute, for instance, enables the scalability principle by mapping logical coordinates to the physical viewport. Nested <svg> elements can be used for grouping or modularization, each with their own attributes like x and y for positioning in embedded scenarios. SVG documents can be embedded in web pages either inline within using the <svg> tag, where the is implicitly applied by parsers, or as external files with the .svg extension referenced via the <img> element (treating it as an with type image/svg+xml) or the <object> element for more interactive integration. External SVG files must include an explicit XML declaration like <?xml version="1.0" encoding="UTF-8"?> and the attribute to ensure compatibility across parsers. For validity, SVG documents are validated against the SVG (DTD) for SVG 1.1 or the RelaxNG for SVG 2, confirming adherence to the language's element hierarchy and attribute constraints. Malformed XML, such as unclosed tags or invalid declarations, results in parsing errors; user agents are required to treat non-well-formed SVG as non-conforming and may ignore erroneous sections or fail to render the document entirely, per XML processing rules. A minimal valid SVG document illustrating the basic structure might draw a simple , as shown below:

xml

<?xml version="1.0" encoding="UTF-8"?> <svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <rect x="10" y="10" width="80" height="80" fill="blue"/> </svg>

<?xml version="1.0" encoding="UTF-8"?> <svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"> <rect x="10" y="10" width="80" height="80" fill="blue"/> </svg>

This example defines a 100x100 square with a blue , confirming the XML syntax and usage.

Scalability and Resolution Independence

SVG achieves through its vector-based rendering, where graphics elements such as paths and shapes are defined mathematically using coordinates rather than raster pixels. This approach allows for precise descriptions of lines, curves, and fills via elements like <path>, <rect>, and <circle>, which specify positions and dimensions in a independent of the output device's resolution. As a result, SVG images can be scaled infinitely without introducing jagged edges or loss of detail, as the rendering engine recalculates the at any . A core mechanism enabling this scalability is the distinction between the and the viewBox. The represents the physical display area available for rendering the SVG content, determined by the embedding context such as an HTML <img> tag or CSS styling. In contrast, the viewBox attribute on the defines a logical by specifying a rectangular region (e.g., viewBox="0 0 100 100"), which maps the SVG's internal coordinates to the . This mapping facilitates zooming and panning without artifacts, as the content is transformed proportionally to fit the , preserving the vector nature of the . SVG supports a variety of units to accommodate both relative and absolute sizing, further enhancing its resolution independence. User units serve as the default, treated as abstract coordinates that scale with the viewBox, while percentages are relative to the immediate parent's or the viewBox itself. Font-relative units like em (relative to the font's em square) and (relative to the x-height) allow text and graphics to adapt to typographic contexts. Absolute units such as px (pixels, approximately 1/96 inch), in (inches), and others like cm or mm ensure consistent sizing across print and digital media. These units enable SVG to maintain proportions across different devices without manual adjustments. Resolution independence is particularly valuable in responsive web designs, where SVG graphics automatically scale to fit varying screen sizes and density. For instance, applying CSS properties like width: 100%; height: auto; to an <svg> element causes it to resize fluidly within its , leveraging the vector definitions to render crisply on high-DPI displays without . This behavior integrates seamlessly with CSS , allowing SVGs to adapt to breakpoints (e.g., adjusting sizes for mobile versus desktop) while preserving quality, unlike formats that require multiple versions. The preserveAspectRatio attribute on the <svg> or <symbol> elements ensures preservation during scaling, preventing distortion when the viewport dimensions differ from the viewBox. By default set to xMidYMid meet, it scales the content uniformly to fit within the while centering it and maintaining the original proportions; alternatives like xMidYMid slice fill the by cropping excess content if needed. This attribute is essential for , icons, and diagrams, guaranteeing consistent visual fidelity across resizes.

Integration with Web Technologies

SVG integrates seamlessly with , allowing it to be embedded directly as an inline element within HTML documents using the <svg> tag, which places the SVG content as part of the page's structure without requiring external files. This inline approach enables SVG to participate fully in the HTML document flow, supporting CSS styling and layout properties like flexbox or grid. Alternatively, SVG can be embedded externally using the <iframe> element for isolated rendering within a dedicated browsing context, or the <object> element for embedding as a replaceable resource, which provides fallback content if the SVG fails to load. These methods ensure SVG's versatility in web pages, from simple icons to complex diagrams. When embedded inline, SVG elements become part of the overall (DOM), allowing direct manipulation through standard APIs such as document.getElementById() to access and modify SVG nodes alongside HTML elements. This unified DOM integration facilitates dynamic updates, such as altering attributes or styles, without switching, enhancing SVG's role in interactive web applications. SVG can hybridize with the for performance optimization, where an SVG image or inline SVG can be rasterized onto a using the drawImage() method to convert vector content to pixels for further manipulation or export. Conversely, canvas-generated raster data can inform dynamic SVG creation, such as by serializing pixel information into vector paths via , though this often requires additional processing for true vector fidelity. This combination leverages SVG's precision for design and canvas's speed for rendering intensive scenarios. To support , inline SVG uses attributes like role="img" to indicate it functions as an , paired with <title> and <desc> elements for descriptive text that screen readers announce. For externally embedded SVG via <img> or <object>, the hosting provides alt text for equivalent purpose, ensuring compatibility with assistive technologies like screen readers that traverse the DOM. attributes such as role="graphics-document" further guide interpretation of complex SVGs as documents, promoting inclusive web experiences. For optimized web delivery, SVGz format applies compression to SVG files, reducing size by 20-50% while maintaining the .svgz extension and type image/svg+xml for browser recognition. This compression is particularly effective for text-heavy SVG, minimizing bandwidth without altering content, and servers can enable it transparently for HTTP transfers.

Graphics Elements

Basic Shapes and Paths

SVG's basic shapes form the foundational building blocks for constructing simple geometric figures directly within the document, enabling efficient rendering of common like rectangles and circles without relying on more verbose path definitions. These elements are defined using straightforward attributes that specify position, size, and orientation in the user , where coordinates are typically expressed in user units that map to the . All basic shapes support filling and stroking to define their visual appearance, which can be applied via presentation attributes or external stylesheets. The <rect> element creates an axis-aligned or rounded . Key attributes include x and y for the upper-left corner position (defaulting to 0), width and [height](/page/Height) for dimensions (must be positive lengths), and optional rx and ry for horizontal and vertical corner radii (defaulting to 0 and clamped to half the width or if larger). For instance, the syntax <rect x="10" y="10" width="100" [height](/page/Height)="100" rx="20"/> draws a square with rounded corners starting at coordinates (10,10). If width or height is zero or negative, the element does not render. Circles and ellipses provide circular . The <circle> element uses cx and cy for (default 0) and r for the (must be positive). An example is <circle cx="50" cy="50" r="40"/>, which renders a circle centered at (50,50) with 40; a zero or negative prevents . The <ellipse> element extends this with separate rx and ry radii for the x and y directions, such as <ellipse cx="0" cy="0" rx="80" ry="50"/> for an aligned with the axes. Both elements outline the starting from the "3 o'clock" position and proceed counterclockwise. Linear elements handle straight-line geometry. The <line> element connects two points with attributes x1, y1 (start, default 0) and x2, y2 (end, default 0), as in <line x1="0" y1="0" x2="100" y2="100"/>; it cannot be filled since it has no enclosed area. For multi-segment lines, <polyline> uses a points attribute listing coordinate pairs (e.g., "0,0 50,100 100,0"), creating an open path that connects the points in order without closing. In contrast, <polygon> closes the shape by connecting the last point to the first, suitable for filled s, with the same points format like "100,10 40,198 190,78 10,78 160,198". Both polyline and polygon points are interpreted in user space, and invalid coordinates (e.g., non-numeric) cause errors. For intricate or irregular beyond basic , the <path> element employs a compact path data syntax in the d attribute to define outlines using a sequence of commands and coordinates, simulating a pen that moves and draws like in editors. Path data supports subpaths, each starting with a moveto command, and can be filled, stroked, or used for clipping; the current point tracks the pen's position after each operation. Commands are case-sensitive: uppercase for absolute coordinates (relative to the origin) and lowercase for relative offsets from the current point. Numbers can include decimals, exponents, or , and commas or whitespace separate values. Path commands include lineto variants for straight segments: L or l (x y) draws to the specified point, H or h (x) for horizontal, and V or v (y) for vertical, with multiple coordinates allowed per command (e.g., "L 100 100 200 200"). Curves are achieved via Bézier commands; the cubic Bézier C or c (x1 y1 x2 y2 x y) uses two control points to define smooth bends, while the smooth variant S or s (x2 y2 x y) reflects the second control point of the previous curve for continuity. Quadratic Bézier curves use Q or q (x1 y1 x y) with one control point, and T or t (x y) for smooth joins by reflection. Arcs are drawn with A or a (rx ry x-axis- large-arc-flag sweep-flag x y), specifying elliptical parameters: radii, angle, flags to choose the larger arc (0/1) and direction (0 for negative-angle, 1 for positive), ending at (x,y); degenerate ellipses (rx or ry ≤ 0) are adjusted to lines. The Z or z command closes the current subpath with a straight line to the starting point, without advancing the current point. A practical example of path data constructs a simple irregular pentagon using moveto, lineto, and closepath commands:

svg

<path d="M 100 100 L 150 50 L 200 100 L 170 150 L 130 150 Z" />

<path d="M 100 100 L 150 50 L 200 100 L 170 150 L 130 150 Z" />

This starts at (100,100), draws lines to each successive point, and closes back to the origin, forming a closed irregular . To optimize path performance and file size, authors should employ concise syntax by omitting optional commas and spaces, use relative coordinates for repetitive patterns, and split long d attribute strings across multiple lines (recommended under 255 characters per line) to aid parsing and tool compatibility, though SVG viewers must handle concatenated correctly. Simplification techniques, such as reducing unnecessary commands or approximating curves with fewer segments, can further minimize length without visual loss, improving rendering efficiency in resource-constrained environments.

Text and Typography

SVG's text rendering is achieved through dedicated elements that allow for precise placement and styling of character strings within . The primary <text> element defines a block of text at specified coordinates, rendering the content as a single inline sequence without inherent line wrapping unless configured otherwise. This element supports international text processing, including bidirectional layouts for scripts like and Hebrew, following the bidirectional algorithm. Positioning is controlled via attributes such as x and y for absolute user-space coordinates, and dx and dy for incremental relative offsets from the prior glyph's position, enabling fine-grained layout adjustments. Alignment is further refined with text-anchor for horizontal positioning (values: start, middle, end) and dominant-baseline for vertical baseline selection (e.g., alphabetic, middle), ensuring consistent rendering across diverse typographic traditions. Within a <text> element, the <tspan> sub-element facilitates segmented styling and positioning, acting as an inline container for portions of the text string. It inherits the parent <text>'s attributes but allows overrides, such as localized x, y, dx, or dy values to shift specific spans, supporting complex layouts like nested emphasis or kerning tweaks without breaking the overall flow. For font integration, SVG leverages CSS properties like font-family, font-size, font-style, and font-weight, applied via stylesheets or inline attributes. Custom fonts are incorporated using the CSS @font-face rule to reference external files, such as WOFF or WOFF2 formats, with fallback mechanisms provided by comma-separated lists in font-family (e.g., a primary custom font followed by generic families like serif or sans-serif if the primary fails to load). This ensures robust rendering, as user agents substitute available system fonts when specified resources are unavailable, aligning with CSS font matching rules. A specialized feature for curved text is the <textPath> element, which places text along the outline of a referenced <path> element, using the xlink:href attribute to link to the path's ID. This enables artistic effects like text following arcs or irregular contours, with layout governed by path and glyph orientation rules that rotate characters tangent to the path's direction. Additional attributes like startOffset control the initial positioning along the path (as a percentage or ), while method (align or stretch) and spacing (auto or exact) dictate how glyphs fit the contour, preserving readability for applications such as or diagrams. SVG 2 introduces enhancements for more advanced , particularly in handling multiline and vertical text. The <text> element now supports automatic line wrapping through the inline-size CSS property, which defines a rectangular content area for reflow, and the shape-inside property for wrapping around custom SVG shapes, improving support for paragraph-like layouts. Vertical writing modes are better accommodated via the writing-mode property (e.g., vertical-rl for right-to-left vertical flow), integrated with CSS Writing Modes Level 3, allowing seamless rendering of scripts like CJK ideographic text with appropriate glyph rotation and baseline adjustments. Further refinements include the textLength attribute for forcing text to a desired length via scaling or spacing (lengthAdjust), and properties like text-overflow for on truncated lines, enhancing usability in responsive designs. Font integration in SVG 2 aligns more closely with CSS Fonts Level 3, mandating WOFF support for features such as ligatures, while deprecating legacy SVG fonts in favor of external web fonts with robust fallbacks.

Images and Linking

SVG graphics can incorporate external raster images through the <image> element, which references files such as or via the href attribute (or the deprecated xlink:href in earlier versions). This element positions the image within a specified defined by x, y, width, and height attributes, rendering it in the current user . The preserveAspectRatio attribute controls how the image scales and aligns within the , with values like xMidYMid meet preserving the while fitting the image to the , or none allowing distortion to fill the space exactly. For example, the following embeds a image:

svg

<image x="10" y="10" width="100" height="100" href="example.png" preserveAspectRatio="xMidYMid meet"/>

<image x="10" y="10" width="100" height="100" href="example.png" preserveAspectRatio="xMidYMid meet"/>

In SVG 2, the href attribute replaces xlink:href and aligns with conventions, while supporting features like CORS via the crossorigin attribute for secure cross-origin fetches. To promote reusability and efficiency, the <use> element allows referencing and instantiating previously defined SVG content, such as shapes or groups stored in <defs> or <symbol> elements. The href attribute points to the target element by ID (e.g., #shapeId) or an external URL, creating a non-editable clone that inherits styles from the <use> context and responds to events as if it were the original. Positioning and scaling are handled by x, y, width, and height on the <use> element, particularly useful for symbols in <symbol> which define reusable viewports. An example reuses a defined circle:

svg

<defs> <circle id="myCircle" cx="50" cy="50" r="40" fill="blue"/> </defs> <use href="#myCircle" x="100" y="100"/>

<defs> <circle id="myCircle" cx="50" cy="50" r="40" fill="blue"/> </defs> <use href="#myCircle" x="100" y="100"/>

This mechanism avoids redundancy in complex diagrams, with the cloned content forming a shadow tree that updates dynamically if the original changes. Hyperlinks within SVG are created using the <a> element, which wraps graphical content to enable upon user interaction, such as clicking. The href attribute specifies the target , supporting both internal fragment identifiers (e.g., #sectionId) and external destinations, while attributes like target control the opening context (e.g., _blank for a new ). For instance, wrapping a to link to an external site:

svg

<a href="https://example.com" target="_blank"> <rect x="10" y="10" width="100" height="50" fill="green"/> </a>

<a href="https://example.com" target="_blank"> <rect x="10" y="10" width="100" height="50" fill="green"/> </a>

The <a> element integrates seamlessly with other SVG features, allowing links on text, paths, or groups, and follows standard processing rules. External references in SVG, via href in elements like <image>, <use>, or <a>, enable linking to other SVG files or resources using absolute or relative , including fragment identifiers to target specific elements (e.g., other.svg#elementId). This facilitates modular designs, such as embedding sub-documents or navigating between files, with the namespace (http://www.w3.org/1999/xlink) used in SVG 1.1 for xlink:href to denote linking semantics. However, external links introduce security considerations, as they can fetch unauthorized resources or enable unintended data exposure if not restricted by user agents.

Styling and Rendering

CSS and Attribute Styling

SVG elements can be styled using presentation attributes directly on the elements or through CSS rules, allowing for flexible control over visual properties such as color, line thickness, and transparency. Presentation attributes, like fill, stroke, stroke-width, and opacity, are XML attributes that specify styles inline, functioning as CSS properties with values parsed according to CSS rules. For instance, a rectangle element might be defined as <rect width="100" height="50" fill="blue" stroke="black" stroke-width="2" opacity="0.8"/>, where fill sets the interior color, stroke the outline color, stroke-width the outline thickness, and opacity the overall transparency. The stroke-dasharray attribute can customize the stroke pattern, such as creating a dashed line with stroke-dasharray="10,5", which specifies alternating segments of 10 units on and 5 units off; this is equivalently applied via CSS, for example circle { stroke-dasharray: 10,5; } on a filled circle to produce a red dashed outline around a yellow interior. These attributes contribute to the author level in the CSS cascade but hold lower specificity (0), making them easy to override. CSS styling integrates seamlessly with SVG, enabling the use of selectors to target elements, such as svg circle { fill: [red](/page/Red); } to color all circles red within an SVG, or more specific rules like .shape:hover { stroke: green; } for interactive states triggered by user events. Styles inherit from parent elements, including from surrounding , allowing SVG to blend with layouts—for example, a div with color: [navy](/page/Navy) can pass that value to child SVG text via the fill property if not overridden. External stylesheets, inline <style> elements, or the style attribute can declare these rules, with CSS properties like fill and stroke applying identically to SVG as to other elements. In the CSS cascade, presentation attributes are treated as author-origin declarations but yield to CSS rules from stylesheets or inline styles with higher specificity or later declaration order; for example, a CSS rule rect { fill: green !important; } will override an attribute's fill="blue". The !important declaration can further enforce precedence in CSS but is invalid in presentation attributes themselves. This hierarchy ensures that declarative CSS maintains control over inline attributes, promoting maintainable designs. SVG introduces specific properties for precise rendering control, such as vector-effect, which modifies how transformations affect elements—for instance, vector-effect: non-scaling-stroke prevents stroke width from scaling during zooms or resizes on paths and shapes. Similarly, clip-path defines a clipping region using an SVG <clipPath> element or basic shapes, restricting visibility to within that boundary, as in clip-path: url(#myClip); referencing a defined path. These properties can be set via attributes or CSS, enhancing SVG's vector nature without altering underlying geometry. A practical example involves styling a path element with a CSS class for dynamic effects:

svg

<svg width="200" height="100"> <style> .path-line { fill: none; stroke: blue; stroke-width: 2; } .path-line:hover { stroke: red; stroke-width: 4; } </style> <path class="path-line" d="M10 50 Q 100 10 190 50" /> </svg>

<svg width="200" height="100"> <style> .path-line { fill: none; stroke: blue; stroke-width: 2; } .path-line:hover { stroke: red; stroke-width: 4; } </style> <path class="path-line" d="M10 50 Q 100 10 190 50" /> </svg>

Here, the base class sets the line style, while the hover pseudo-class adjusts it on user interaction, demonstrating CSS's role in responsive SVG visuals.

Gradients, Patterns, and Filters

SVG provides mechanisms for creating complex visual effects through gradients, patterns, and filters, which extend basic solid color fills to enable smooth color transitions, repetitive textures, and post-processing modifications to graphical elements. These features are defined as reusable paint servers or filter resources within the <defs> element, allowing them to be referenced by ID across the document for efficient rendering. Gradients in SVG enable smooth color interpolations between multiple points, using the <linearGradient> and <radialGradient> elements. A linear gradient is specified by defining start and end points via attributes such as x1, y1, x2, and y2, with color transitions controlled by child <stop> elements that set offset, stop-color, and stop-opacity values ranging from 0 to 1 (or percentages). For example, a simple linear gradient might be defined as:

<linearGradient id="linearGrad"> <stop offset="0%" stop-color="blue"/> <stop offset="100%" stop-color="red"/> </linearGradient>

<linearGradient id="linearGrad"> <stop offset="0%" stop-color="blue"/> <stop offset="100%" stop-color="red"/> </linearGradient>

This gradient is then applied to shapes or paths using fill="url(#linearGrad)" or stroke="url(#linearGrad)", with options for coordinate units (gradientUnits) and transformations (gradientTransform) to adjust orientation and scaling. Radial gradients, defined with <radialGradient>, use center points (cx, cy), radii (r, fr), and focal points (fx, fy) to create elliptical or circular fades, similarly populated with <stop> elements. In SVG 2, mesh gradients are introduced via <meshGradient>, employing bicubic patches (Coons patches) for more sophisticated, non-linear color blending across irregular surfaces, enhancing capabilities for realistic shading. Patterns allow for tiled fills using the <pattern> element, which defines a reusable graphic—such as paths, shapes, or even other gradients—that repeats across a specified area. Key attributes include x, y, width, height for the tile bounds, patternUnits for coordinate scaling, and patternTransform for rotation or skewing. For instance:

<pattern id="tilePattern" width="50" height="50"> <circle cx="25" cy="25" r="20" fill="green"/> </pattern>

<pattern id="tilePattern" width="50" height="50"> <circle cx="25" cy="25" r="20" fill="green"/> </pattern>

This pattern is referenced like gradients, via fill="url(#tilePattern)", supporting complex, non-uniform textures while maintaining vector scalability. SVG 2 extends patterns with support for external references via href and hatch patterns for simple stroked lines. Filters provide image-processing effects through the <filter> element, which contains primitive operations applied to source graphics before compositing. Filters are referenced using the filter="url(#filterID)" attribute on target elements, with the filter region bounded by x, y, width, and height attributes. Common primitives include <feGaussianBlur>, which applies a Gaussian kernel blur controlled by stdDeviation (e.g., stdDeviation="5" for moderate softening), useful for glows or softening edges. Color adjustments are handled by <feColorMatrix>, which uses a 5x4 transformation matrix or predefined types like saturate or hueRotate to modify RGB channels, enabling effects such as grayscale conversion. Shadows are created with <feDropShadow>, combining offset (dx, dy) and blur (stdDeviation) on the alpha channel. Morphological operations via <feMorphology> perform dilation or erosion with a specified radius and operator, altering shape boundaries for thickening or thinning outlines. For procedural textures, SVG's <feTurbulence> primitive generates Perlin noise patterns, configurable with baseFrequency for scale, numOctaves for detail layers (up to 10 typically), and type as fractalNoise for smooth variations or turbulence for sharper contrasts, simulating natural phenomena like clouds or water. These primitives chain together within a single <filter>, processing inputs like SourceGraphic or SourceAlpha to produce layered effects while preserving SVG's resolution independence.

Transformations and Coordinate Systems

In SVG, coordinate systems define the spatial context for rendering , distinguishing between the viewport coordinate system, which establishes the initial rendering region, and the user coordinate system, which maps abstract units to that viewport and can be modified by transformations. The viewport is a rectangular area determined by the dimensions of the embedding element, such as an <svg> tag's width and height attributes, with its origin typically at the top-left corner and positive x-axis to the right and y-axis downward. In contrast, user space starts identical to the viewport but allows scaling, , and through the viewBox attribute or the transform , enabling resolution-independent positioning that builds on SVG's vector scalability foundations. Object space refers to the local of individual elements, such as the bounding box of a path before any transformations are applied, which is crucial for relative positioning in attributes like gradients. The transform attribute, or equivalently the CSS transform property, applies 2D affine transformations to elements, groups, or the entire SVG, altering their position, size, or orientation relative to the current user space. Common transformation functions include translate(tx [ty]) for shifting by tx units along the x-axis (and ty along y if specified, defaulting to 0); scale(sx [sy]) for uniform or non-uniform scaling (sy defaults to sx); rotate(angle [cx cy]) for rotation by angle degrees around the point (cx, cy) if provided, otherwise the origin; skewX(angle) and skewY(angle) for shearing along the respective axes; and matrix(a b c d e f) for a general 2D affine transformation. These can be chained in a single transform list, composing via where later transformations are post-multiplied to earlier ones, forming a cumulative current transformation matrix (CTM) that maps user coordinates to coordinates. The viewBox attribute on the root <svg> element or nested <svg> viewports establishes the initial by defining a rectangular region (min-x min-y width height) that is scaled and translated to fit the , preserving via the preserveAspectRatio attribute to ensure uniform scaling. For instance, viewBox="0 0 100 100" maps a 100x100 unit abstract space to the actual dimensions, allowing content to scale responsively without distortion. In nested SVGs, such as an inner <svg x="25%" y="25%" width="50%" height="50%">, coordinates are relative to the parent 's user space unless overridden by a local viewBox or transform, enabling modular, hierarchical layouts. At its core, SVG's transformations rely on 2D affine , where each operation corresponds to a 3x3 matrix of the form (acebdf001)\begin{pmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \end{pmatrix}
Add your contribution
Related Hubs
Contribute something
User Avatar
No comments yet.