W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2009

[whatwg] <code> attributes

From: ddailey <ddailey@zoominternet.net>
Date: Fri, 5 Jun 2009 14:36:36 -0400
Message-ID: <1E26AFDA4F374D9BABC0CBBB4DF52871@disxgdg31szkx7>
Hi Ian,

>> 1. Having to type <pre><code>&lt;tagname></code></pre> seemed a little 
>> bit
>> silly to me:
>> is there a use case for *not* wanting <pre> when doing <code>? Could that 
>> not
>> be handled as an attribute of the <code> if so?
>
> <code> is used a lot to refer to method names and the like, where the
> contents aren't preformatted. (For example, HTML5 uses <code> over 14,000
> times but <pre> only about 500 times currently.)

Oh, okay, I see. But for the very common case in which there is a block of 
code how about something like
<code type="pre">
<html>
       <p>happy</p>
</html>
</code>

instead of
<pre><code>
<html>
       <p>happy</p>
</html>
</code></pre>
? (assuming the '<' s have all been escaped one way or another)

Thanks for your example:

<p>Type <code>ls <var>dir</var></code> to see what's in the directory
<var>dir</var>.</p>

it explains the basic reasoning, but still befuddles me a bit, I guess. It 
seems like the number of folks needing to preserve HTML functions inside 
code as in this example,  might be smaller than the number of folks doing 
XML or HTML, so why not make the smaller group do the extra work, instead of 
the others?

That is, the parser has to, it seems, have an exception that says either
    a) don't render the &lt; literally but as <
 or
    b) when inside <code> don't render the <var></var> (phrasing content?) 
tags literally but as their HTML equivalents

No big deal, as I can see your point.  I tried reading up on the distinction 
between phrasing and non-phrasing content in
http://dev.w3.org/html5/spec/Overview.html but that document (dated June 5, 
2009) seems to be crashing both FF and IE for me this afternoon..

On the other hand,
a simple

<code lang="xml/html">

could be used to introduce the <pre> and all the &lt; s

I do miss <xmp> whenever I have to do this sort of stuff.

cheers
David 
Received on Friday, 5 June 2009 11:36:36 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:13 UTC