Re: nesting block level elements

At 05:04 PM 10/22/99 -0400, Alan G. Isaac wrote:
>Is it correct that HTML 4 forbids
>nesting other block level elements
>in a P element?

Yes. Also HTML2.0 and HTML3.2, for that matter.

>How then is one supposed to markup
>a paragraph containing several lines
>of computer code? 
>The obvious coding would be to have a
>PRE element nested in the P element.
>(The phrase element CODE is not useful 
>for this, even if it might be in some 
>perverse sense correct.)

If preserving white space is important, then PRE 
is the only practical option, but it can't be in a <p>.

CSS has a white-space property (chapter 16.6 in CCS2 
http://www.w3.org/TR/REC-CSS2/text.html#white-space-prop ), 
but it applies only to block level elements, so you're out of luck 
if you want to apply it to inline content. 

>
>If this question is not list-appropriate,
>can someone please point me to an 
>enlightening discussion elsewhere.
>
>Thank you,
>Alan Isaac
>
>PS A similar question arises in the context
>of math displays, if these will be block
>level (will they?), since these are often 
>an integral part of a paragraph.

HTML is not designed for math. One can use MathML 
to display mathematical expressions inline in an XML document.

In principle one can embed MathML inline in HTML documents
using <object>, 
but there isn't much support in browsers right now (you'll need plugins to 
actually see the math). Also you can use <IMG> inline, but this 
means that you display the math using images, not MathML.
The latter seems the only practical method nowadays, unless you 
are willing to use PDF.

Regards,
Nir.
 
===================================
Nir Dagan
Assistant Professor of Economics
Brown University 
Providence, RI
USA

http://www.nirdagan.com
mailto:nir@nirdagan.com
tel:+1-401-863-2145

Received on Friday, 22 October 1999 18:28:42 UTC