Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > text and <p>

Reply
Thread Tools

text and <p>

 
 
Clues
Guest
Posts: n/a
 
      04-07-2006

Hi,
I must separate some text blocks.

I started by doing the following:

<p>
texttxtxtxtxtxtxtxtxtxtxtxtx<br />
texttxtxtxtxtxtxtxtxtxtxtxtx
</p>

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:

<div>
<p>textxtxtxtxtxtxtxtxt</p>
<p>tetxtxtxtxtxtxttxtxtx</p>
</div>

?

I thank you very much.
Clues

 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      04-07-2006
Clues wrote:

> I must separate some text blocks.


> <p>
> texttxtxtxtxtxtxtxtxtxtxtxtx<br />
> texttxtxtxtxtxtxtxtxtxtxtxtx
> </p>


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

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


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
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      04-07-2006
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?
 
Reply With Quote
 
Clues
Guest
Posts: n/a
 
      04-07-2006

Thanks Yukka and David,
now anything appears clearer

Clues
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make a text bar that users can scroll through and be able to highlight the text?!?!! loshbolton@hotmail.com HTML 1 03-10-2006 10:40 PM
Controlling text in a Text Area or Text leo ASP General 1 12-05-2005 01:13 AM
Read Text File and split them to individual text file Krish ASP .Net 1 10-20-2005 03:39 PM
How to Put Both Left-Justified Text and Right-Justified Text on the Same Line? jaykchan@hotmail.com HTML 5 06-29-2005 07:01 PM
Text boxes and read-only text Julie ASP .Net 2 05-12-2004 06:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57