Re: [whatwg] Pre, code and semantics in HTML5: Wishful thinking?

2008-07-24 Thread Geoffrey Sneddon


On 22 Jun 2008, at 21:22, Edward Z. Yang wrote:


To represent a block of computer code, the pre element can be used
with a code element; to represent a block of computer output the pre
element can be used with a samp element. Similarly, the kbd element
can be used within a pre element to indicate text that the user is to
enter.


The implication is that document authors are recommended to use
 to wrap all of their programming code instead of a lone
, if they wish to be fully semantic. This feels needlessly  
verbose

and abusive of , which traditionally has been used to mark
single-liners.


Well, that tradition is wrong under HTML 4.01 (pre "tells visual user  
agents that the enclosed text is 'preformatted'", whereas code  
'designates a fragment of computer code').



It also makes it extremely difficult to style pre as a block for code,
as the only semantic indication that the contents of the pre block are
computer code is its child. You'd end up having to say  if you wanted to style pre as well.


There are lots of thing that are semantically desirable in HTML that  
can't be fulfilled using pre-existing CSS selectors. Continuing to  
style "pre" is no less ambiguous and risky as it was under what the  
traditional behaviour is.


At the same time, I still think the semantics of whether or not a  


tag indicates a plaintext file, or a piece of ASCII art, or computer
code, is somewhat important. However, I think this information would  
be

more appropriately given as an attribute.


Why go against what HTML 4.01 does? It seems needless to change.


--
Geoffrey Sneddon




Re: [whatwg] Pre, code and semantics in HTML5: Wishful thinking?

2008-06-22 Thread Thomas Broyer
On Sun, Jun 22, 2008 at 11:36 PM, Edward Z. Yang wrote:
>
> Smylers wrote:
>> Why would you need to -- surely you could just put the styling on the
>>  instead (using pre + code to select only  elements inside
>> -s)?
>
> Lets say I want to place a background image of a computer behind spanses
> of computer code, but a background image of a console for emulated
> console data using samp and kbd.
>
> With HTML 4, I would have done  (or more likely, just
> omitted it and assumed it was computer code by default unless otherwise)
> and .

Which you can do with HTML 5 too...

> With , you can't do that.

print "Hello world!"
[EMAIL PROTECTED]> rm -Rf 
/

>  is an inline element, and
> the background image doesn't get applied to it in any meaningful way.

Wouldn't display:block fix this problem? (theoretically, using
margin:0 would too, IIRC)

> I suppose one of the primary distinctions is that if you use
> , it's usually because all of it's computer code.

Yep, so you'd use a class=console for your console samples and the
following CSS rule for  (untested):

pre + code:only-child {
  display: block;
  background-image: url(computer.png);
}

-- 
Thomas Broyer


Re: [whatwg] Pre, code and semantics in HTML5: Wishful thinking?

2008-06-22 Thread Smylers
Edward Z. Yang writes:

> ... authors are recommended to use  to wrap all of their
> programming code instead of a lone , if they wish to be fully
> semantic. This ... makes it extremely difficult to style pre as a
> block for code, as the only semantic indication that the contents of
> the pre block are computer code is its child. You'd end up having to
> say  if you wanted to style pre as well.

Why would you need to -- surely you could just put the styling on the
 instead (using pre + code to select only  elements inside
-s)?

Smylers


Re: [whatwg] Pre, code and semantics in HTML5: Wishful thinking?

2008-06-22 Thread Edward Z. Yang
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Smylers wrote:
> Why would you need to -- surely you could just put the styling on the
>  instead (using pre + code to select only  elements inside
> -s)?

Lets say I want to place a background image of a computer behind spanses
of computer code, but a background image of a console for emulated
console data using samp and kbd.

With HTML 4, I would have done  (or more likely, just
omitted it and assumed it was computer code by default unless otherwise)
and .

With , you can't do that.  is an inline element, and
the background image doesn't get applied to it in any meaningful way.

I suppose one of the primary distinctions is that if you use
, it's usually because all of it's computer code.

- --
 Edward Z. YangGnuPG: 0x869C48DA
 HTML Purifier  Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIXsX1qTO+fYacSNoRAgFhAKCFytkJ985PnqJDnDDQCfkUd4/EIwCeL9Mr
gqBmVDkEAT12wpOARzogoNc=
=XwlH
-END PGP SIGNATURE-


[whatwg] Pre, code and semantics in HTML5: Wishful thinking?

2008-06-22 Thread Edward Z. Yang
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I was reading through the HTML5 spec the other day and I noticed this
tidbit:

> To represent a block of computer code, the pre element can be used
> with a code element; to represent a block of computer output the pre
> element can be used with a samp element. Similarly, the kbd element
> can be used within a pre element to indicate text that the user is to
> enter.

The implication is that document authors are recommended to use
 to wrap all of their programming code instead of a lone
, if they wish to be fully semantic. This feels needlessly verbose
and abusive of , which traditionally has been used to mark
single-liners.

It also makes it extremely difficult to style pre as a block for code,
as the only semantic indication that the contents of the pre block are
computer code is its child. You'd end up having to say  if you wanted to style pre as well.

At the same time, I still think the semantics of whether or not a 
tag indicates a plaintext file, or a piece of ASCII art, or computer
code, is somewhat important. However, I think this information would be
more appropriately given as an attribute.

Thanks for reading,
Edward

P.S. Please CC my address on all replies.

- --
 Edward Z. YangGnuPG: 0x869C48DA
 HTML Purifier  Anti-XSS Filter
 [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIXrSQqTO+fYacSNoRAn1WAJ95X7i0Rf4sMGuj4n5qEEWoEH4CuwCfUnP8
TIADRZ6VRXWK2AC9tIATl8E=
=TY06
-END PGP SIGNATURE-