text and

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I must separate some text blocks.

I started by doing the following:

texttxtxtxtxtxtxtxtxtxtxtxtx<br />

and using a CSS to style <br />

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

The question:
in XHTML, is it legal to do something like this:



I thank you very much.

Re: text and

Clues wrote:

Quoted text here. Click to load it

That would be a single block (the paragraph), with a line break in it.

Quoted text here. Click to load it

Two paragraphs in a generic block? Of course.

David Dorward       <http://blog.dorward.me.uk/ <http://dorward.me.uk/
                     Home is where the ~/.bashrc is

Re: text and

Clues wrote:

Quoted text here. Click to load it

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?

Quoted text here. Click to load it

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.

Quoted text here. Click to load it

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>.

Quoted text here. Click to load it

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?

Re: text and

Thanks Yukka and David,
now anything appears clearer   :-)


Site Timeline