[whatwg] <p> elements containing other block-level elements

Lachlan Hunt lachlan.hunt at lachy.id.au
Tue Apr 12 04:32:50 PDT 2005


Ian Hickson wrote:
> On Tue, 12 Apr 2005, Lachlan Hunt wrote:
> 
>>>We haven't discussed it yet. I hadn't really thought about it but given:
>>>
>>>   <pre><code> ... </code></pre>
>>>   <blockcode> ... </blockcode>
>>
>>To use <pre><code> like <blockcode>, one would have to style it with
>>
>>  pre>code:only-child { display: block; }
> 
> Hm? Why?

Oh, sorry.  I assume your asking about why display: block;?  I think I 
explained why I used :only-clild well enough before.

Where this is the need to apply styles to block of code, such as a 
background colour or border, but those styles don't need to apply all 
pre elements in general.  So, the solution is to either use
   <pre class="code"><code/></pre>
with
   pre.code { background-color: silver; }

Or use:
   <pre><code/></pre>
with:
   pre>code:only-child { display: block; background-color: silver; }

As I said, though, the chances of that affecting a code element within a 
pre that is not supposed to be block (ie. the e-mail example I gave 
before) are very slim.

>>I don't understand what's wrong with the XML error handling...
>
> I myself have occasionally made typos and other mistakes that, if I had 
> used XML, would have left my site unusable, without my knowledge, for 
> several hours at a time.

Don't you check your site after publishing anyway? Would you not have 
caught the error while previewing in your browser, before publishing? 
Although, as I said earlier, a CMS should enforce the well-formedness 
too, not just the end user.

-- 
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox




More information about the whatwg mailing list