AntipixelNo one knows je ne sais quoi like us

Electronic Kindness < Home > Tokyo MT Gathering


Parsermancy

Comments: 12


Parsermancy is Eric Meyer’s word for various CSS tricks that deliver different snippets of style to particular browsers based on their quirks. It’s what I’ve had to resort to thanks to Internet Explorer.

A while back I got mail from a reader suggesting that since the site is coded in XHTML, I shouldn’t be sending it as text/html. Fair enough, so I removed that meta tag. I need to specify the UTF-8 encoding, though, so I added the XML declaration back to the top of the pages – <?xml version="1.0" encoding="UTF-8"?> – and was only reminded that this sends IE6 back into it’s fucked-up box model mode while trying to find a fix on Tantek Çelik’s box model hack page (scroll way down to the bottom).

The answer came from Albin.net, whose “be mean to Opera” hack can quickly be adapted to send a different column width to IE, which I can only hope and pray is working for those of you afflicted with the browser (actually, I’m the one who’s afflicted with it).

So although it may be fixed, the worst has happened: we’re back to the bad old days of sending different instructions for different browsers.

•••
Posted to MetaStuff 2003.01.12 (Sun) • 23:58

Comments

Posted by Erik   2003.01.13, 00:21

It looks the same for me with Phoenix and IE6.0 on Windows XP.

One recommendation though, your top graphic, extend the blue graphic out wide, because when I opened your site full screen, the horizontal tiling of your top graphic showed picture twice. The second time, it was behind the header at the top and looked really out of place. Email me if you want a screenshot showing what I am talking about.

Posted by Zach   2003.01.13, 02:54

Hey, your page is fixed! I’ve been looking at your page for a while but it had that quirk in IE6. Well, good work. It looks great!

Posted by Kris   2003.01.13, 02:56

Your DocType: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/ DTD/xhtml1-strict.dtd">

According to the following specification (appendix C of the XHTML specification, [1]), you are not obligated to serve XHTML1.0 (transitional or strict) as application/xhtml+xml. The MIME type text/html is fine (though you then miss out on all the benefits that XHTML conformant parsers may offer — remember that all versions of Miscrosoft Internet Explorer do not know a way to cope with XHTML served as application/xhtml+xml). Know that XHTML1.1 requires this MIME type.

[1] http://www.w3.org/TR/xhtml1/#guidelines

Since the default encoding of XHTML is UTF-8, you are not required to have an XML prologue at the top of the document under XHTML1.0. That is only required for an encoding different than UTF-8.

“Be aware that processing instructions are rendered on some user agents. Also, some user agents interpret the XML declaration to mean that the document is unrecognized XML rather than HTML, and therefore may not render the document as expected. For compatibility with these types of legacy browsers, you may want to avoid using processing instructions and XML declarations. Remember, however, that when the XML declaration is not included in a document, the document can only use the default character encodings UTF-8 or UTF-16.”

http://www.w3.org/TR/xhtml1/#guidelines

Not having an XML declaration at the top prevents MIE6 from applying that hideous bug; dropping into non-standards mode.

Be sure to send the document from the server with appropriate character encoding, UTF-8, since it is authorative. However, bad browsers like MIE5+/Win have a tendency of ignoring every server-specified MIME type and go out making their own guess, which may result in interpreting your document as ISO-8859-1 (or whatever the default is for the browser). I make it a habit of always including a META element that specifies content type. Not only as an extra, but as a requirement for MIE5+/Win to get things right. It also comes in handy for when people save the document locally (thus, no headers can be sent since there is no server).

Summarized: 1). Leave out the XML prologue, in order to avoid having MIE6/Win to drop into non-standards mode; 2). Serve your document as Content-type: text/html; charset=utf-8 from your server, as is permitted for XHTML1.0; 3). Include the following META tag in the HEAD of your documents: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> to make sure MIE5+/Win to not mess up the encoding and as a commodity for people who store the page locally.

<poor disclaimer> I hope I didn’t make any errors in this : ) </poor disclaimer>

Posted by Kris   2003.01.13, 03:00

By the way, I am doing a hell of a job here putting in ACRONYM, BLOCKQUOTE, CITE, EM and what’s more in my reply, and it looks great in preview mode, but when I post it it is all stripped out.

:’(

Posted by jh   2003.01.13, 17:00

Erik — I know what you mean about the header image. It’s a matter of trying to balance the smallest number of bytes against the greatest number of horizontal pixels. Just for you, I’ll see what I can do (even though I’m jealous you’re looking at a lot more resolution than I am ;-).

Kris — Thanks for the great comment. Haven’t had time to read through it carefully but will certainly do so and go over the spec citations you provided.

Moving to XHTML 1.1 might render some points moot, but we’re not there yet.

Apologies for the screwed up comment — it should be fixed.

Posted by victor   2003.01.13, 18:07

When seeing the site with IE 6.0: the type size has increased (I’d say by two bumps or three) and this sends the right column appears again below the left one.

As for the background image: just use repeat-none instead of repeat-x

Posted by jh   2003.01.13, 19:51

Victor — Nothing should have changed with the font sizing (there was no difference for me in IE6 after making the column size adjustment yesterday).

Does the font sizing pull-down menu work on the main page? Even selecting the X-large option shouldn’t break the layout in IE6.

Posted by victor   2003.01.13, 20:25

This is strange. When the page loads, the font size is larger than when I select X-large. If I select medium or small, everything works as expected. I haven’t changed nothing on my side. I will check with other cow-orkers computers, and let you know. BTW, once I fix the font size, the columns display properly.

Posted by Kris   2003.01.13, 21:04

Victor:

As for the background image: just use repeat-none instead of repeat-x

That should be the value no-repeat (property: background-repeat).

jh:

Moving to XHTML 1.1 might render some points moot, but we’re not there yet.

Like, with MIME type application/xhtml+xml (contrary to the for XHTML1.0 allowed text/html), all versions of Explorer get in trouble (prompting to save the file instead of rendering it, degrading to HTML). Loosing your entire MSIE audience is a little bit bigger than some moot points. :)

Apologies for the screwed up comment — it should be fixed.

Thanks. This reply puts it to the test.

Posted by Kris   2003.01.13, 21:09

jh: “Apologies for the screwed up comment — it should be fixed.”

Unfortunately, it still doesn’t work, though the source shows that the tags are present. I think it is due to the script that parses the replies (BRs to P, etcetera). This document will not validate either.

Will give you a function i wrote in PHP that does a fine job parsing custom ‘usertags’ that we allow clients to use in their CMS, maybe it can be of use:

function parsetxt($text) { $text = “<p>”.$text.”</p>”; $text = strreplace(“\n”, “”, $text); $text = strreplace(“\t”, “”, $text);

/* [kop][/kop] / $text = preg_replace(“/[kop](.?)[\/kop]\r\r/si”, “</p>\n<h2>\1</h2>\n<p>”, $text); $text = pregreplace(“/[kop](.*?)[\/kop]\r/si”, “</p>\n<h2>\1</h2>\n<p>”, $text); $text = pregreplace(“/[kop](.*?)[\/kop]/si”, “</p>\n<h2>\1</h2>\n<p>”, $text);

/* [subkop][/subkop] / $text = preg_replace(“/[subkop](.?)[\/subkop]\r\r/si”, “</p>\n<h3>\1</h3>\n<p>”, $text);
$text = pregreplace(“/[subkop](.*?)[\/subkop]\r/si”, “</p>\n<h3>\1</h3>\n<p>”, $text);
$text = preg
replace(“/[subkop](.*?)[\/subkop]/si”, “</p>\n<h3>\1</h3>\n<p>”, $text);

$text = strreplace(“\r\r”, “</p>\n<p>”, $text); $text = strreplace(“\r”, “<br />\n”, $text); $text = str_replace(“<br />\n</p>\n”, “</p>\n”, $text);

/* [sterk][/sterk] / $text = preg_replace(“/[sterk](.?)[\/sterk]/si”, “<strong>\1</strong>”, $text);

/* [nadruk][/nadruk] / $text = preg_replace(“/[nadruk](.?)[\/nadruk]/si”, “<em>\1</em>”, $text);

/* [link=][/link] / $text = preg_replace(“/[link=()?(.?)](.*?)[\/link]/si”, “<a href="\2">\3</a>”, $text);

$text = strreplace(“<p></p>”, “”, $text); $text = strreplace(“<p>\n</p>”, “”, $text);

return $text; }

Posted by smoothj   2003.01.14, 00:20

Well, as a designer who is still making the transition to css/xhtml and all that- these suggestions are great. But to jeremy’s final point, aren’t we just slipping back into the same old game of coming up with hacks and tricks and arcane coding knowledge? What’s different except the code? Parsermancy indeed. Where’s the payoff?

Posted by lukas   2003.08.26, 00:34

there is no pay-off….

running into more horrible stuff than this now myself, not with styl, not even with xhtml, jsut with plain good’ol http…

yes, just try and tell a browser that is watching your site it should not cache it :) that is a barrel of laughs, may seem wierd for xhtml but I am using php… you have no idea :) browser caching can be temporarily turned off either through http headers and/or meta tags and IE, netscape and mozilla ingore the headers completely :D

it’s doomsday kid..

Post a comment:

*

* (not displayed)


Remember personal info?
(optional)


* Required
You can use basic HTML below, but URLs don't link automatically.



Make HTML-safe: convert

To help reduce comment spam, you must preview your comment before posting. Sorry about this, but I'm borderline homicidal with the spam crap.

Send This Story to an Enemy









• • •

Search Options

Possibly Related Entries

  • No related entries found

Complete Archives


Valid XHTML


Antipixel

Antipixel.com
© 2006 Jeremy Hedley
All rights reserved and so forth.
Rights & Administrivia
Privacy info