[whatwg] <code> attributes
Tab Atkins Jr.
jackalmage at gmail.com
Fri Jun 5 12:21:17 PDT 2009
On Fri, Jun 5, 2009 at 1:36 PM, ddailey<ddailey at zoominternet.net> wrote:
> Hi Ian,
>
>>> 1. Having to type <pre><code><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)
What's the benefit here? In either case you have to type 11
characters to indicate that whitespace is important. In the latter,
though, it works in legacy clients as well.
> 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?
I doubt that. It's very common to want to format the text inside a
code block. At minimum you often want to bold and italicize
particular things, but you may have an automated syntax colorer that
can output to html, in which case you want the ability to output
arbitrary tags and classes
There's also the simple fact that making a change like this would
completely break a large amount of existing content that relies on the
fact that they can use HTML normally within a <code> element. The
benefit (you don't have to type <) seems pretty minor for this
major downside.
> On the other hand,
> a simple
>
> <code lang="xml/html">
>
> could be used to introduce the <pre> and all the < s
This is the one part of the suggestion that I could possibly see being
introduced in the language, but the benefit is *still* very small.
~TJ
More information about the whatwg
mailing list