[Twisted-web] .htc behaviors

Dominic Fox dominic.fox at gmail.com
Wed Aug 11 15:24:22 MDT 2004


As you may know, the current version of MSIE doesn't support the css
:hover selector properly for elements other that <a>. There is a hack
to fix this, which involves attaching an IE "behavior" to the document
via CSS, as follows:

body { behavior: url(csshover.htc); }

and serving the csshover.htc file (which defines the behaviour using
jscript) along with the .css and .htm files as static content. The
hack is documented here:


In order to get this to work with servers other than IIS, you need to
set the MIME type for files with the .htc extension to be
'text/x-component', otherwise the behavior won't be loaded properly.

This doesn't work using Twisted (specifically, using
twisted.web.static.File to serve the page, stylesheet and behavior).
You can serve the file, and you can set the MIME type by adding it to
mimetypes.types_map, but the behavior still isn't loaded.

One fix is to change the extension to something else, e.g. .htcHACK,
and set the MIME type for that extension instead. That works OK. But
why does it work, and why is it necessary? Is something else in
Twisted deciding that all files with .htc extensions are Twisted
documentation pages, and forcing the content type header back to


// Dream in black and white -
// model cities, shooting up in the air

More information about the Twisted-web mailing list