[whatwg] <code> attributes
ian at hixie.ch
Wed Jul 1 20:52:35 PDT 2009
On Tue, 9 Jun 2009, Jonas Sicking wrote:
> On Thu, Jun 4, 2009 at 6:24 PM, Ian Hickson<ian at hixie.ch> wrote:
> > On Tue, 28 Apr 2009, Jacob Rask wrote:
> >> has there ever been any discussion on including an attribute to the
> >> code element, specify the programming language in the markup? If so,
> >> what was the conclusion? I didn't find anything in the list archives.
> > On Tue, 28 Apr 2009, Michael A. Puls II wrote:
> >> For example: <code class="language-python"></code>
> > This has been discussed before, but the basic answer is "use the class
> > attribute", at least for now. I would recommend, if this is a
> > common-enough problem, that a group of people get together and define
> > a common set of class attribute values for the <code> element, in the
> > style of a Microformat. That way, we can build a common vocabulary
> > that can then be made more formal in the next version of HTML.
> Is there a reason you encourage class values rather than microdata here?
> As I understood it, one of the things microdata was trying to avoid was
> using the class attribute since there was concern that it would collide
> with user values.
I suppose you could use microdata if you wanted to, but it's not clear to
me what the benefit would be. The goal here is typically to allow an
element to be annotated (class attribute), not to allow a set of
name-value pairs to be included alongside the markup (microdata).
To do this "right" in microdata, you'd have to do something like:
<pre item="com.example.code"><code itemprop="com.example.text">
<meta itemprop="com.example.lang" content="python">
... my code ...
...to end up with an item that has a "com.example.text" property with the
code in question and a "com.example.lang" property with the language,
whereas with a class attribute you just need to do something like:
... my code ...
...and define that the "com.example.python" class automatically implies
that the content of the element in the code in question.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg