On Mon, Sep 10, 2007 at 12:59:50PM +0100, David Reynolds wrote:
Chris,
On 10 Sep 2007, at 12:51 pm, Chris G wrote:
Is there really no way to set a lot of margin-top and margin-bottom values for paragraphs without explicitly setting a class= for each paragraph where you want to change the default?
Other things (like font-size and alignment) can be changed by wrapping a set of paragraphs in a <DIV>....</DIV> and setting the values in the DIV's class but margin-top and margin-bottom are not inherited so this doesn't work for margins.
All I want to do is have a set of paragraphs with bigger margins than the default and it looks as if I'll have to do:-
<P class=bigmargin>..............</P>
for every paragraph, which rather defeats the object of using CSS, I might just as well write the margin size there.
How about:
div#content p { /* set your css stuff here */ }
All p tags within the div of id content will have the stuff defined above.
Aha, thanks, that does it. It works for a class as well which is what I really wanted:-
div.content p {/* set your css stuff here */ }
It's the explicit 'p' that makes it work for paragraphs in the div block.
It can even be reduced to:-
.content p {/* set your css stuff here */ }
for more general use.
Also, if you're writing XHTML, then you should have all of your parameters wrapped in quotes:
<p class="bigmargin">....</p>
Yes, I know, the sample wasn't actually pasted from real code.
I don't write enough CSS/HTML to have the rules (and good practice) like this embedded in my fingers.