I have a sketch that I want to put up on my website, and I also intend to write a short play at some point which I'd also want to make freely available.
I'm trying to work out the best way of representing this in HTML. I basically need two columns - one for the character speaking, and one for the text. Each speech obviously needs to line up with the speaker though. In other words, something like this:
Jeff This sure is a nice website we've got now. Joel It certainly is. By the way, working at FogCreek rocks. Jeff Of course it does. Have you played Rock Band yet? It's a lot of fun.
(Well it's better than lorem ipsum...)
I know how I could do this with HTML tables (with one table row per speech) but that seems pretty ugly, and everyone certainly seems to be keen on using CSS to represent non-tabular data. I can't see how this really counts a tabular data - my use of "row" and "column" earlier was to do with the layout rather than the fundamental data.
So, any ideas? I think most of the script websites I've seen (not many, admittedly) either use <pre>
like my example above, or don't bother trying to keep the normal script format, instead just prefixing each paragraph with the speaker's name. (See the podcast wiki for an example of this style.) I'm having trouble working out even what HTML elements I should be using to represent this, frankly - a dictionary definition list with the speaker as the term and the speech as the definition is probably the closest I've thought of, but that feels like abuse.
My favourite example of marking up something like this is one of Tantek's XHTML compounds http://tantek.com/presentations/2005/03/elementsofxhtml/ (check out the conversation bit)
In summary it goes like so:
Not sure how you'd mark up stage directions etc... Maybe you'll end up creating a new microformat :)
Also that markup has some ideal CSS hooks, with discrete LInes unlike a definition list.
Tables is the way to go.
Anything else like messing around with <div>s and css or XSLT is just reinventing the <table> but with a c**p syntax.
I would go for three or four fixed width colums. (Any non-trivial play is going to need stage directions, special effects, sound effects etc.).
I would use headers and paragraphs.
With the following styles it would arrange as you presented it:
I second the heresy :-)
Always good to consider CSS before resorting to tables - but often tables really are the best fit. It looks like it in this case.
The only additional consideration would be accessibility. I've heard that tables make it harder for text reader software to process tables, but I don't see why this would be the case (feel free to comment here if you know more).
One other thing - I presume you'd be holding the raw data in some other format first - perhaps a database, or xml or some other structured text?
In any case, getting it into an xml format and tranforming that to html with xslt can be quite liberating when it comes to playing with this stuff.
Please avoid the "sledge hammer syndrome" (if your only tool is a hammer, you try to treat every problem like a nail). HTML is a representation language, not a source language.
So my suggestion is to write the play in something which can represent your thoughts best (not necessarily XML) and then convert that to HTML. For my own works, I'm using a recursive XML parser which can fall out of XML parsing for certain elements:
My parser will invoke a custom parser to parse the content of
<content>
. In my case, it will create an intermediate XML tree:This tree is then converted into HTML, TeX, PDF, whatever.
[EDIT] My strategy to come up with a compact language works like this: I start with XML. After a while, I look at the XML and try to see patterns. Then I think how I could express these patterns in a more compact way 1.) as XML, 2.) as XML text (with custom markup) and 3.) as something else entirely. When an idea hits me, I write a parser for the new format.
Frankly, writing parsers which can turn something into XML for automatic background processing is a minor task, today.
If you want to do it semantically, I would use labels, something like:
That degrades pretty nicely and I think the label is a bit more appropriate for what you're trying to do. And then, in your style sheet, I would style it something like Eran Galperin's example CSS.
The other suggestion I would have, if you're serious about this, would be to look further into how dead tree scripts are written and do your utmost to preserve their style. This will help ensure that it looks familiar (read professional) to your audience.