Cooking with Webstandards! Taste the full flavour of the Web

Next entry: H121: Blogging Software | Previous entry: Writing your weblog

The mysterious image selector

Consider the following CSS-styles:

image {
float: right;
}

You'd never expect this one to work, don't you? But surprise, it actually works in 2 browsers: Internet Explorer 6 and Opera 7.x. I am not surprised by Internet Explorer (I never am), but when Opera applied this style, I didn't want to believe it.

Further tests with Opera and a discussion in the Opera forum (thanks Anne) have nailed it down:
It seems to be a misbehaviour of Opera's SGML parser, since the CSS declaration only applies when the page is served as text/html. When served as application/xhtml+xml Opera's XML parser takes over and correctly ignores the style.

Served as text/html
HTML 4.0 Strict/URI
XHTML 1.0 Strict without XML PI
Served as application/xhtml+xml
XHTML 1.0 Strict with XML PI
XHTML 1.0 Strict without XML PI

Go see for yourself. Ahhh, and yes. Mozilla doesn't apply the styles at all!!!!

Posted by Minz Meyer at April 01, 2004, 12:44 PM | To Top