|
Posted by Jukka K. Korpela on 07/28/06 10:10
rathernots@googlemail.com <rathernots@googlemail.com> scripsit:
> Hi! I can't believe this simple issue hasn't been raised before:
As a rule of thumb, especially when you wish to get answers from gurus, get
to the point as early as possible. If neither the Subject line nor the first
sentence says the least of what the &mildcurse; you are talking about, the
odds are that the gurus won't even read your question.
> Create a new html document, in the body, type:
>
> <p>TEST1<br><br></p>TEST2
Why? A <p> element is a block element (and tends to have default top and
bottom margins, by browser defaults), so what's the point of saying "line
break!" at the end of a paragraph? And saying it _twice_? How many times can
you break a line? The only thing you will really achieve that way is an
experiment on browsers' behavior with this illogical markup, including some
odd behaviors like treating <br><br> as implying one or two empty lines.
Besides, TEST2 appears to be "loose" text - text not wrapped in any
block-level container. That's valid in HTML 4.01 Transitional but not good
style and not valid in HTML 4.01 Strict.
> IE will create a small amount of white space between the two lines,
> while gecko will place quite a lot more.
Perhaps. So what?
> Question: how can this be controled via CSS?
Not really. CSS is not for control. And I don't mean just control freaks.
The answer to the question that you probably _should_ have asked is this:
add class attributes and remove the <br> tags to get
<p class="foo">TEST1</p>
<p class="bar">TEST2</p>
(Naturally, you should replace foo and bar with some meaningful names,
depending on the role of the paragraphs.)
Then you can say in CSS:
p.foo { margin-bottom: 0; padding-bottom: 0; }
p.bar { margin-top: 0; padding-top: 0; }
if you want _no_ vertical spacing between the two paragraphs. If you want
some specific spacing, set exactly one of those properties to that value and
set the others to zero as above.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Navigation:
[Reply to this message]
|