Internet Explorer 9 Guide for Developers
March 14, 2011
Scalable Vector Graphics (SVG)Support for Scalable Vector Graphics (SVG) has become one of the most requested features for implementation in Internet Explorer, and is a powerful way to add high-fidelity, easily scalable visuals—from small and simple to large and complex— to a website without the need for a plug-in or separate viewer. With Internet Explorer 9, Microsoft is proud to introduce support for the basic SVG feature set. The SVG support in Internet Explorer 9 is based on the SVG 1.1 (Second Edition) specification recommendation (for desktop browsers). The following functionality has been implemented:
Internet Explorer 9 supports the following methods to display SVG markup:
For more information about SVG support in Internet Explorer 9, see MSDN. For more information about SVG, see the svg element reference page on MSDN. Basic ShapesInternet Explorer 9 introduces support for the parsing and rendering of all the basic shapes elements, their attributes, and associated DOM interfaces, as specified in the Basic Shapes module of the SVG 1.1 (Second Edition) specification. The set of basic shapes supported by Internet Explorer 9 consists of the following shapes elements: Internet Explorer 9 also supports these elements’ associated DOM interfaces. Following are examples of each of the aforementioned shapes elements. After the markup is a screenshot of the corresponding result in Internet Explorer 9. Rectangles: rect Element<?xml version="1.0" standalone="no"?> <rect fill="orange" For more information, see the rect element reference page on MSDN. Circles: circle Element<circle fill="orange" For more information, see the circle element reference page on MSDN. Ellipses: ellipse Element<ellipse stroke="orange" For more information, see the ellipse element reference page on MSDN. Lines: line Element<!-- vertical --> For more information, see the line element reference page on MSDN. Polylines: polyline ElementA “polyline” is defined in SVG to be several connected lines, often forming an “open” shape, or a polygon with one or more missing sides or non-convex shapes. <polyline points="15, 5, 100 8,3 150" For more information, see the polyline element reference page on MSDN. Polygons: polygon ElementA polygon is a closed shape. <polygon points="15, 5, 100 8,6 150" For more information, see the polygon element reference page on MSDN. Clipping, Masking, and CompositingInternet Explorer 9 supports SVG clipping, clip paths, masking, and opacity as specified in the Clipping, Masking, and Compositing module of the SVG 1.1 (Second Edition) specification. (SVG paths are discussed in the Paths section of this document.) ClippingA clipping path cuts or “clips” the area that a color, pattern, or image can be drawn. All parts of the graphical element that lie outside the clipping path are not drawn. Clipping paths are fully opaque; the portion of the graphical element that is outside the clipping path is completely invisible. In SVG, the overflow and clip properties establish initial clipping paths, or shapes in which content will be displayed. By default, the initial clipping path is defined as the SVG viewport, or the rectangular area of the page where the SVG content is displayed. The clipPath element defines a clipping path. The clipping path is then referenced using the clip-path property. The clip-rule property applies to graphic elements within a clipPath element, and the clipPathUnits attribute defines a coordinate system for the contents of the clipPath. Clipping paths can be applied to text as well as colors, patterns, and images. Clipping functionality can be accessed programmatically with the SVGClipPathElement DOM interface. Following is a simple example of an SVG clipping path. <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> This example uses the clipPath element to define a clipping path in the shape of a circle. The clip-path property is then used to apply the clipping path to a rectangle. This produces the following in Internet Explorer 9. MaskingA mask is similar to a clipping path, except it is semi-transparent. Masks are often used for compositing foreground objects into the current background. The mask element defines a mask. The mask is then referenced using the mask property. The following is a simple example of an SVG mask. <?xml version="1.0" standalone="no"?> This example uses the mask property to define a mask in the shape of three adjacent circles with different colors. The mask property is then used to apply the mask to a purple rectangle. This produces the following in Internet Explorer 9. Coordinate Systems, Transformations, and UnitsInternet Explorer 9 introduces support for SVG coordinate systems, transformations, and units as specified in the Coordinate Systems, Transformations and Units module of the SVG 1.1 (Second Edition) draft specification. The features supported by Internet Explorer 9 include:
Internet Explorer 9 also supports the DOM interfaces associated with SVG coordinate systems and transformations. Document StructureInternet Explorer 9 introduces support for basic SVG document structure, metadata, and extensibility functionality, as specified in the Document Structure, Metadata, and Extensibility modules of the SVG 1.1 (Second Edition) specification. The elements supported by Internet Explorer 9 include: Internet Explorer 9 also supports these elements’ associated DOM interfaces. Gradients and PatternsSVG provides the ability to paint or stroke shapes and text using color, gradients, or patterns. Internet Explorer 9 supports SVG gradients and patterns, as specified in the Gradients and Patterns module of the SVG 1.1 (Second Edition) specification. GradientsGradient support is provided through the gradient elements (linearGradient and radialGradient) and attributes (gradientUnits and gradientTransform). Gradient colors are defined by the stop element. The gradient elements can be used in the fill and stroke properties of SVG shapes. For example, consider the following markup: <svg version="1.1" xmlns="https://www.w3.org/2000/svg"> This markup defines a rectangle with a linear gradient. The two stop elements specify color stops along a vector for the color transitions—a yellow one at the 10% point and a blue one at the 90% point. This appears as follows in Internet Explorer 9: PatternsPattern support is provided through the pattern element and its attributes. Like gradients, pattern elements can be used in the fill and stroke properties of SVG shapes. For example, consider the following markup. <svg version="1.1" xmlns="https://www.w3.org/2000/svg"> In this example, the pattern element defines a pattern that consists of an alternating small blue square and tiny yellow circle. The ellipse that is then specified is given a fill of the pattern. The following image shows how this appears in Internet Explorer 9. InteractivitySVG content can be interactive—that is, it can change in response to user input. Internet Explorer 9 supports SVG interactivity features, as specified in the Interactivity module of the SVG 1.1 (Second Edition) specification, including:
Internet Explorer 9 also supports the Interactivity module’s SVGCursorElement DOM interface. Additionally, the Internet Explorer 9 supports the focusable attribute as specified in the Interactivity module of the SVG Tiny 1.2 specification. The following markup shows a very simple example of SVG interactivity in action. <svg xmlns=https://www.w3.org/2000/svg When this snippet is loaded, it displays a small red circle. Clicking the circle causes it to grow to twice its size. The same effect can be achieved with mouseover and mouseout events, which will cause the circle to grow and shrink just by moving the cursor over and off of it. ... Linking and ViewsSVG enables linking out of SVG content to other pages, as well as predefined views of SVG documents. Views are useful when you want to link directly to, for instance, a close-up of a diagram. Internet Explorer 9 supports SVG linking and views, as specified in the Linking module of the SVG 1.1 (Second Edition) specification. This includes support for the a and view elements. The Linking module’s associated DOM interfaces—SVGAElement and SVGViewElement—are also supported. LinkingJust like in HTML, the a element is used to create a hyperlink in SVG. For instance, the following markup provides a hyperlink on a rectangle. <svg width="100%" height="100%" version="1.1" ViewsViews can be used to instruct the browser to display an SVG image in a certain way. For instance, the following markup defines a link to a view. ... In this example, the The following markup defines another link to a view. ... In this example, the When you click “Go to Circle”, the Painting and ColorPainting and color are essential components of SVG. The concept of painting encompasses fills (solid color, gradients, patterns), strokes (lines drawn along paths), and marker symbols (applied to the end of line segments; for instance, arrowheads), and can also incorporate opacity. Fills and strokes can apply to paths, text, and shapes. Internet Explorer 9 introduces support for SVG painting and color, as specified in the Painting: Filling, Stroking and Marker Symbols module and the Color module of the SVG 1.1 (Second Edition) specification. This includes support for:
The Painting module’s associated DOM interfaces—SVGPaint and SVGMarkerElement—are also supported. Several examples of fills and strokes in SVG are included in the Paths section of this document. PathsSVG paths are outlines of shapes. They can be filled in, stroked (a line is drawn along the path), or used as clipping paths (cutouts of other shapes). Internet Explorer 9 introduces support for SVG paths, as specified in the Paths module of the SVG 1.1 (Second Edition) specification. This includes support for the path element, as well as the d property, which enables parsing of path data. The Paths module’s associated DOM interfaces are also supported. The path element enables many different developer scenarios. Following are just a few simple examples. After the markup is a screenshot of the corresponding result in Internet Explorer 9. Closed Shape with Straight Lines and a Fill<?xml version="1.0" standalone="no"?> Bezier Path (Quadratic)<path d="M20,30 Q40,50 60,30 T100,30" Line with Arc<path d="M30,60 l 50,0 a25,45 0 0,1 50,0 l 50,0" TextSVG documents can include text. Text is rendered just like other graphic elements in SVG, which means that coordinate system transformations, painting, clipping, and masking can all be applied to text. Internet Explorer 9 supports text rendering, as specified in the Text module of the SVG 1.1 (Second Edition) specification. The text element specifies the characters to be drawn. Because SVG does not break lines or wrap words automatically, you must determine line breaks in advance. To adjust text properties (such as font, weight, color, kerning, and many others) within a line of text, SVG provides the tspan element. Internet Explorer 9 also supports the Text module’s associated DOM interfaces. |