W3C home > Mailing lists > Public > public-html@w3.org > May 2007

Re: <code type="...">

From: Patrick H. Lauke <redux@splintered.co.uk>
Date: Sat, 26 May 2007 00:43:18 +0100
Message-ID: <46577496.3080000@splintered.co.uk>
To: public-html@w3.org

Josh Sled wrote:
> <code> should have a type attribute, which indicates the media type of the
> inlined content(-fragment).

Some might say that HTML is already strangely specific for computing 
type applications, with its inclusion of <code>, <var>, <samp>, <kbd>. 
Further refining these elements seems weird, considering that other 
areas are still arguably lacking more adequate elements to better mark 
up content.

> As a use-case, a (hypothetical) javascript library -- say, during body onLoad
> -- could parse and syntax-hilight [[[
>     <pre><code type="text/x-python-source">
>     def foo():
>         return [x**2 for x in range(10)]
>     </code></pre>
> ]]] differently from [[[
>     <pre><code type="application/json">
>     {'foo': ['bar', 'baz','quux'],
>      'bar': 42,
>     }
>     </code></pre>
> ]]] in a blog posting using such code as examples.

Your use example seems to suggest that you'd want it mainly for styling 
reasons...in which case I'd argue that this could be more appropriately 
solved by using class attributes (but not by reserving those in the spec).

> Extending, user-agents might dispatch to external handlers or formatters
> based on @type.

Handlers? Are you proposing that <code> should actually be *executed*?

> Also, I note the analog with <object type=...>.

But <object> actually *does* something, as opposed to <code> whose 
purpose is to mark up a code fragment for display/presentation, not 

Patrick H. Lauke
re·dux (adj.): brought back; returned. used postpositively
[latin : re-, re- + dux, leader; see duke.]
www.splintered.co.uk | www.photographia.co.uk
Co-lead, Web Standards Project (WaSP) Accessibility Task Force
Take it to the streets ... join the WaSP Street Team
Received on Friday, 25 May 2007 23:43:36 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:21 UTC