[Pmwiki-users] vspace paragraphs

Val Sharp val
Thu Nov 4 06:24:50 CST 2004


Patrick R. Michaud, on 04.11.04 01:46, wrote:
 > On Wed, Nov 03, 2004 at 11:23:43PM +0000, Val Sharp wrote:
 >
 >>- if the block is terminated by another block-markup item, then it's
 >>given a class which sets the bottom-margin to zero, and the following
 >>item is give a class which sets its top-margin to zero.
 >
 >
 > This requires a bit of a lookahead, since the block has to be able
 > know what the subsequent lines will generate before it can generate
 > its text.  For example:
 >
 >    * one
 >    ** two
 >    ** two
 >    ** two
 >    * ONE
 >    Some text
 >
 > at the time the first "* one" line is generated, it has to search 
all of
 > the subsequent lines until it finds the end of the list (i.e., at
 > Some text) before it can know if it needs to have the bottom margin
 > suppressed.
 >
 > And it gets a fair bit harder with
 >
 >    # one
 >
 >    # two
 >
 >    # three
 >    some text
 >
 > because simply finding a blank line probably should not cause the
 > (numbered) list to terminate.
 >
 > Somehow I think the <p class='vspace'></p> solution is cleaner.  :)


Bearing in mind that HTML4.01 says:

"We discourage authors from using empty P elements. User agents should
ignore empty P elements."[1]

then one might argue that the <p class='vspace'></p> solution is far
from clean.

Logically, it's what's following the block in question that determines
the margin, so a bit of a look-ahead seems fair. And after all, if one
were writing HTML and CSS from scratch to render the same layout,
adjusting the top and bottom margins would be the obvious
standards-conforming way of doing it. But I'll have to admit, I have
little idea of how hard that would be to implement here - you'll know
that far better than me  :-)


[1] <http://www.w3.org/TR/html4/struct/text.html#edef-P>

Though in some discussion of this in the W3C mailing lists, Dan
Connolly, chairman of the HTML WG at the time, says

"If I were writing the spec today, I'd say:

	"The P element represents a paragraph [...]. As paragraphs in
	conventional usage are not empty, this specification assigns
	no meaning to an empty paragraph. Authors should include
	at least one character, word, image, or form control
	in each paragraph.

		"NOTE: historically, user agents have rendered
		empty paragraph elements as vertical whitespace,
		and authors have exploited this behaviour by
		using empty P elements to control the layout
		of their documents on those user agents.

		"For reliable whitespace control, authors should
		use stylesheets. For example, see section XYZ
		of the CSS spec."
<http://lists.w3.org/Archives/Public/www-html/2000Apr/0126.html>

In practice today, this means that conforming browsers in 'standards
mode' will not render any vertical space for <p></p>, but will still
allow for an empty P element to be styled so that it does create
vertical space (- and scripts will still be able to manipulate the
attributes, content, and properties of an empty P element).

So, even in 'standards mode', there's no risk of the
<p class='vspace'></p> solution not working ... it's just contrary to
the intended use of the element.


-- 
Best regards,
Val Sharp - Edinburgh



More information about the pmwiki-users mailing list