Skip navigation.

Fyrdility

A blog about Web Development, Web Standards, Opera, and Related Pleasantries

Posts tagged with "CSS"

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.

For now, some of my personally biggest peeves with this beta:
  • Oddly enough, IE8 does not ignore the IE5/Mac Band Pass Filter hack. I've used this in a few places on my site, so I'm not too happy about that. But not a huge issue, I suppose
  • The "clear" style fails. I use this a lot too.
  • Data URIs are limited to images, won't work in the address bar, and have a size limit of 32kb.
  • Generated content is limited, not allowing images or background images, which was one of my main purposes for using it.
  • No SVG, XHTML, or CSS3 (aside from box-sizing and vertical text).
  • Some new proprietary features have been added.


It rather seems like they aimed at passing Acid2 first, supporting the absolute minimum amount of features to pass it. This seems to be the opposite of the IE team's initial view of Acid2, which basically was that it would focus on supporting features first, which would then result in Acid2 support.

I'm optimistic though, that this was done just out of laziness, but rather to quickly show the web developing community their new dedication to supporting standards. I strongly suspect the limitations will be gone by the time IE8 ships. They're definitely on the right track, and I'm delighted they decided to make this beta public, which didn't seem to be the plan initially.

For comments, please post at IE8 beta 1 first impressions on the new Fyrdility blog

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!

Usage

  1. Make sure you have matching SVG and fallback images.
  2. Rename your fallback images in this format: "filename.svg.jpg" for "filename.svg". Note that any image type can be used as alternative (jpg, png, gif, etc).
  3. Make sure your file names are correct in you HTML and CSS files
  4. Add the script inside your HEAD element like this:
    <script type="text/javascript" src="svgreplace2.js"></script>
    and of course upload the script to your server.
  5. If you already have a script with an onload event, you can remove that line in the script, then just call SvgReplace(); where it needs to load. Note that the script will also work when the DOM is loaded, so it should work fine (actually better, since the images will be replaced faster) if you if you want to call it then.

How it works

First, the script checks if the browser recognizes SVG files as images. It does this by loading a small data URI SVG file, then checks if it loads properly and if it returns it's width. When true, it looks through all CSS rules, and replaces image background names that contain '.svg'. Then it does the same for all images that appear in the HTML.

Browsers tested

To make sure the script will work for future browsers, the script was rewritten to check support for PNG files. The following browsers were able to check for this support and replace the images successfully. When tested for SVG image support, all displayed the fallback images as expected.
  • Opera 9.2
  • Firefox 2
  • Safari 1.2
  • Safari 3
  • Internet Explorer 6
  • Internet Explorer 7

Opera 9.5 beta 1 and two different developer snapshot builds were used to test the SVG support, which also works as expected. This leaves the following browsers that should successfully replace specified images with their SVG counterparts:
  • Opera 9.5 alpha / beta 1
  • Wii Internet Channel

As for support by other browsers...

Webkit (Safari) apparently supported SVG as images in its nightly builds for a while, but the feature was disabled for stability reasons. Hopefully they'll manage to stabilize it soon, in which case it should appear in an upcoming release of Safari in the near future. See bug report

Gecko (Firefox) has the feature reported as a bug, both for images as well as CSS backgrounds. Unfortunately, no priority or target milestone has been set for either, though quite a few people have voted for them. So it might be while before we see any support there.

Internet Explorer does not support SVG natively at all right now, and the only thing we know for future support comes from this comment by IE Platform Architect Chris Wilson: "I think SVG is gaining momentum as part of the interoperable web standards platform, and as such I expect we will add support for it in the future". Who knows, maybe they'll support SVG as images when they get to it?

Notes

  • While other browsers do support SVG files using the "embed" or "object" elements, this script currently only checks for support as "img" elements and CSS background images.
  • Theoretically a future browser might support SVG as images, but not as CSS backgrounds, or vice-versa. I've been unable to find a way to differentiate these different supports, so the script will just assume support for both if support for "img" elements is found.
  • As mentioned, a data URI file is used to check support. This was done to eliminate the need for an additional file. All modern browser support data URIs, except for Internet Explorer. Then again, all modern browsers support SVG to some degree, while IE does not. Hopefully by the time IE supports SVG and SVG as images/css backgrounds, it will also support data URIs. If you don't expect this to be the case, you can play it safe by using an external SVG file instead. Just change the "testImg" value to the location of a small SVG file.
  • Opera 9.5 appears to have a strange bug where it occasionally gets unhappy when you try to use the same SVG image as both a CSS background as well as a regular image. Doing so using this script may make Opera use the fallback image, or worse, hide the background entirely.


For comments, please post at SVG Image and Background Image Replacer on the new Fyrdility blog

SVG Background Replacement Script

, , ,

UPDATE: I've managed to create a working version! See here.

I've written this excellent script that will replace specified background images with an SVG image, whenever support for this is detected. It will go through all CSS rules looking for "filename.svg.jpg" and replace it with "filename.svg". This should be ideal for anyone who would prefer to use SVG backgrounds whenever possible.

There's one problem: It doesn't work in the one browser that supports SVG background images! Homer: Doh!

Since the script does work when detecting support for/replacing, say, PNG files, I can only assume this is an issue in Opera. I have thus reported this issue in the forums.

Hopefully this will be fixed before Opera 9.5 goes final, if not, it's back to the drawing board to write a script that's more forgiving!

For comments, please post at SVG Background Replacement Script on the new Fyrdility blog