Categories
Web development

SVG test page

I have created a test page to determine how current web browsers deal with SVG in HTML, using an SVG file as an OBJECT element, an IMG element, or as CSS background.

My main purpose for this was to discover the limitations of Webkit’s ability to display SVG files as CSS backgrounds, after which I thought it might be helpful to show the other methods too.

Here is the SVG test page.

Currently, only Opera 9.5+ is able to render all the instances correctly.

Webkit (Safari, Chrome) appears to only be able to display SVG as CSS backgrounds under the following conditions:

  1. The HTML container may not larger than the width and height set in the SVG file
  2. The SVG file must have a width and height set
  3. Only elements in the SVG file with pixel rather than percentage positioning will appear

Similar restrictions exist for images.

There doesn’t appear to be a specification that states how SVGs should be handled in CSS backgrounds, so technically there’s nothing that says that Opera’s more flexible rendering is any more correct than Webkit’s. However, having more restrictions than it does on regular images seems odd. Tiling the image, for example, is not possible in Webkit.

Hopefully Webkit will at some point adopt Opera’s method, until then it’s limited to fixed width vector images in fixed width containers. Gecko, in the mean time, continues to have open bug reports for CSS in image as well as CSS, and anything from IE will have to wait until IE9 or a sudden switch to Webkit.

Categories
Opera blog post Web development

IE8 beta 1 first impressions

Anyone who cares has heared that IE8 beta 1 has just been released, with quite a bit of documentation.

Mark “Tarquin” Wilton-Jones offers a pretty good overview of the changes. Many are good, and I’m especially happy with the Acid2 support and the decision to make the IE8 rendering mode the default. It is also important to note that there is still “much more” expected in beta 2.

Categories
Opera blog post Web development

Sad day for web standards

Update: Less sad since IE7 mode is no longer the default mode

It is a sad day for web standards.

Winners: Microsoft and lazy web developers
Losers: Alternate browsers and forward-thinking web developers

Categories
Opera blog post Web development

SVG Image and Background Image Replacer

It’s here! A working version of the SVG image replacement script.

Purpose

This script substitutes specified images and background images with SVG images for web browsers that support them. This makes it perfect for anyone who would like to start using SVG for their site design, but wants to make sure it will look okay for browsers that do not yet support it.

Features

  • Future-proof – Checks for actual support, no browser sniffing
  • Unobtrusive – Only affects browsers with support, uses fallback content without support or if javascript is disabled
  • Simple to use – Just include one javascript file to your pages and use the appropriate image names
  • Small file – Only 1.8 KB!