You are here: Re: text and <p> « HTML « IT news, forums, messages
Re: text and <p>

Posted by Jukka K. Korpela on 11/05/78 11:44

Clues wrote:

> I must separate some text blocks.

Apparently you wish to make some vertical empty space appear between
them in visual rendering. Have you consider how things work in
non-visual rendering?

> I started by doing the following:
>
> <p>
> texttxtxtxtxtxtxtxtxtxtxtxtx<br />
> texttxtxtxtxtxtxtxtxtxtxtxtx
> </p>
>
> and using a CSS to style <br />

That's a wrong approach. The <br> tag means just 'line break'. It
specifically does not separate blocks; it is by definition inline
(text-level) markup. Besides, the odds of styling it successfully are small.

> #content br {margin: 0; padding: 0; border-width: 0; line-height: 2em;}
> but I was unhappy with the result.

No wonder. What does line height mean for nonexistent lines? Besides, br
elements have by default display: none, in CSS terms, together with a
fancy rule for br:after to implement the presentational semantics of <br>.

> The question:
> in XHTML, is it legal to do something like this:
>
> <div>
> <p>textxtxtxtxtxtxtxtxt</p>
> <p>tetxtxtxtxtxtxttxtxtx</p>
> </div>

Of course it's "legal" syntactically. The simple syntactic question can
easily be resolved by consulting the specifications, and there is no
difference between HTML and XHTML in this respect. Whether it is
_semantically_ "legal" depends on what you have their inside the <p>
elements (and on the applicable jurisdiction of semantics).

But beware that by using <p> you effectively invoke some default top and
bottom margins for each <p> element, so you need to be careful to avoid
getting too much spacing. As regards to making the spacing between the
paragraphs e.g. 2em, it suffices in practice to the margin-bottom: 2em
for the first paragraph.

However, if the two blocks are logically parts of the same paragraph,
the situation is more tricky. You would need to resort to a workaround like

<p><span class="part1">textxtxtxtxtxtxtxtxt<br /></span>
<span class="part2">tetxtxtxtxtxtxttxtxtx</span></p>

with something like

..part1, .part2 { display: block; }
..part2 { margin-top: 2em; }

(The <br /> is there to ensure a line break in non-CSS visual rendering.
The first <span> is there just as a matter of logic.)

On the other hand, if parts of a paragraph should be set so much apart
from each other, do they really constitute a paragraph?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация