Using bookmarklets to experiment with CSS
I’m in the middle of a whole bunch of exams at the moment, but here’s a quick tip that should make experimenting with and learning CSS a great deal easier. It involves bookmarklets. If you haven’t seen them before, bookmarklets are bookmarks that embed javascript; when you click the bookmark, the javascript is executed in the context of the currently loaded page. What that means is that in a suitably advanced browser bookmarklets can be used to modify pages, analyse their structure and do a whole host of other useful things.
A fair number of bookmarklets work in both IE and Gecko engine browsers, but the really interesting ones (at least as far as learning CSS is concerned) tend to be Gecko only. If you’re serious about learning CSS it’s well worth getting a Gecko browser at any rate—Gecko’s CSS support is more standards compliant than anything else currently available, so I recommend designing for the standards with Gecko and tweaking to support IE afterwards. Some people advocate designing for IE because it has buggier support, but once you’ve seen the tools available for Gecko I think you’ll agree it really is a superb development platform. If you don’t have access to a Gecko engine browser (that means Mozilla, Netscape 7, Camino, or Phoenix/Firebird) go and grab Firebird—it’s only a 6 MB download and is available for most major platforms.
Now that you’re tooled up with a good browser, drag the following links on to your links toolbar or add them as bookmarks:
- test styles
- edit styles
- ancestors
- zap style sheets
- zap presentational html
- view style sheets
- show blocks
Now give them a go. They’re all useful, but by far the most useful for learning CSS are test styles and edit styles. test styles opens a popup window in which you can type CSS rules that will be applied instantly to the page you are viewing, while edit styles does the same thing but pre-populates the window with the style sheets of the current site, allowing you to edit them in place. ancestors is also useful; it shows the element hierarchy of the element your mouse is currently over, which can help you see what selector you need to use to modify that element’s style. I cannot emphasize enough how powerful this is for working with CSS; using test styles I was able to redesign this site entirely in less than half an hour!
All of the above bookmarklets were written by Jesse Ruderman. Jesse has many more bookmarklets, all of which are available on his site. The bookmarklets listed above are from his Web Development collection (which includes further descriptions of these and many others). Jesse’s bookmarklets have saved me countless hours of development time, and I hope they can do the same for you.
Martin - 3rd June 2003 14:29 - #
chris - 3rd June 2003 15:14 - #
Mike - 3rd June 2003 15:49 - #
Chris,
Mozilla isn't so crappy compared with Opera when you take the context into consideration. When developing a layout, standards-compliance is crucial, and Opera still isn't in a position to beat Mozilla in that respect.
Jim - 3rd June 2003 16:28 - #
liorean - 3rd June 2003 17:54 - #
Jesse Ruderman - 3rd June 2003 18:12 - #
liorea: That reminds me, Opera doesn't support XSLT/XSL-FO (no biggie on the FO). They do support some of the cooler parts of css2, though, which gecko does not.
ninja - 3rd June 2003 20:12 - #
BongoMan - 4th June 2003 00:15 - #
Adam - 4th June 2003 01:39 - #
BongoMan: The Safari team has already fixed one problem with bookmarklets that I reported (window.open() with no parameters would open a file called "undefined" instead of about:blank). I don't know if they've released a version with that fix. I also don't how many of my bookmarklets are still broken in Safari for other reasons (such as using non-standard stuff supported by both Mozilla and IE).
I don't spend a lot of time testing bookmarklets on Macs, and right now I don't even have access to a Mac. If you have a Safari build where the window.open() bug is fixed, I'd be interested to know which bookmarklets work and which don't. And of course, if you buy me a Mac, I'll fix everything I can quickly.
Jesse Ruderman - 4th June 2003 03:54 - #
Anon - 5th June 2003 10:07 - #
MikeyC - 8th June 2003 01:00 - #
Chris Pederick - 10th June 2003 05:33 - #
Ian Lloyd - 10th June 2003 13:32 - #
Hiram - 10th June 2003 23:18 - #
MikeyC,
Tantek works for Micro$oft, so of *course* he's gonna call them 'favelets' rather than 'bookmarklets'. As much of a CSS god as Tantek is, I'm fairly sure that 'bookmarklets' was the term that was in use first, way back in the days of Netscape 4, when www.bookmarklets.com (no less!) found its way onto my radar.
Oh, and Simon - it's nice to see Bath's finest getting a plug at Dive into Mark...
Tim - 12th June 2003 08:52 - #
VIncent - 10th July 2003 19:57 - #
vxbv - 23rd August 2003 20:11 - #
Tim: "I'm fairly sure that 'bookmarklets' was the term that was in use first, way back in the days of Netscape 4, when www.bookmarklets.com (no less!) found its way onto my radar."
I agree. It is odd, however, that the W3C appears to endorse the term 'favelet' over 'bookmarklet'.
See: Favelets For The Validator
MikeyC - 15th October 2003 05:24 - #
anon - 23rd March 2004 19:36 - #
Azaman - 4th October 2005 06:13 - #
Duk - 14th October 2006 17:40 - #