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

[whatwg] <code> attributes

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 5 Jun 2009 14:21:17 -0500
Message-ID: <dd0fbad0906051221y521855c9qf57df1fd043b9db9@mail.gmail.com>
On Fri, Jun 5, 2009 at 1:36 PM, ddailey<ddailey at zoominternet.net> wrote:
> 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)

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 &lt;) 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 &lt; 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
Received on Friday, 5 June 2009 12:21:17 UTC

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