Skip to Main Content
Painting the Web
book

Painting the Web

by Shelley Powers
May 2008
Beginner content levelBeginner
656 pages
17h 41m
English
O'Reilly Media, Inc.
Content preview from Painting the Web

Browser Support: Standoffish or Integrated

Not all browsers support SVG equally, and Internet Explorer doesn't support SVG at all. Of the other popular browsers, most will process standalone SVG files but differ in how SVG is integrated directly into web pages.

The Hello, World example in Chapter 7 was a standalone SVG document, saved with an .svg extension and served with a MIME type of image/svg+xml. These separate SVG files can be accessed directly or incorporated into a web page using either the embed or object element or via an iframe. Of the three, embed is a deprecated element, and iframe isn't XHTML Strict compliant, though it does validate with XHTML Transitional. The only element that's valid with XHTML 1.0 Strict is the object element. Since this element is supported by Firefox 2.x and 3, Safari 3.x, and Opera 9.x, that's the only element I'll use to demonstrate incorporating a separate SVG file into a web page.

SVG Through the object Element

Once you have a valid, working SVG file (tested by opening it directly into a browser that supports SVG), you can then incorporate it into a web page.

To get things started, Example 7-1 contains a web page with an SVG file incorporated into the page through an object element. The object is modified through a style attribute, which sets the width and height and adds a border. The external SVG file is the second Hello World example from Chapter 6.

Example 7-1. Using the object element to embed an external SVG file

<!DOCTYPE html PUBLIC "-//W3C//DTD ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 9780596515096Supplemental ContentErrata Page