Wandering Thoughts archives

2006-05-02

CSS and syndication (another CSS limitation)

In an earlier entry on Solaris patch exit codes I mentioned that its formatting might not look very nice in syndication feeds. And I was right; it did not look very good.

It didn't look good because it was styled with CSS, and you can't really put CSS in syndication feeds. CSS goes into the HTML <head> element, but that only appears in HTML pages; syndication feeds and entries are divorced from that sort of context. This is more or less implicit in RSS (like a lot of things), but is explicit in Atom 1.0; both HTML and XHTML entries must be markup that is valid inside a <div>.

(Technically you can wedge a certain amount into style="..." attributes on elements, but you can't get everything. And it significantly bulks things up. And apparently a number of feed readers strip style attributes because they can contain various dangerous things, like JavaScript.)

You can substitute deprecated HTML features for some things, but not always. For example, in the earlier entry, I had a 'horizontal' table, one where the important thing was the relationships between the columns in the same row; in CSS it has light thin horizontal lines after each row. In syndication feeds I eventually decided that the best approximation (or at least the least annoying to me) was for there to be no borders at all.

Because of this limitation and my desire for my entries to be decently readable in feed readers, I've generally held back from making much use of CSS in WanderingThoughts. Sometimes it's very tempting, though; for example, I really like the CSS appearance of 'horizontal' tables. (I'm willing to live with them not looking good in lynx, for fuzzy reasons.)

Because WanderingThoughts generates HTML from higher level markup, I'm actually better off than many people; I could in theory render entirely different HTML for the Atom feeds (inlining styles and all that) than for regular page views. (The Atom feed already changes some stuff, for example to make all links into absolute URLs.)

(Credit where credit is due department: I got the idea for the 'horizontal' table style from how CJ Silverio's Snippy styles tables.)

web/CSSAndSyndication written at 02:12:31; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.