On Mon, Sep 10, 2007 at 01:06:32PM +0100, Richard Lewis wrote:
On Monday 10 September 2007 12:51:02 Chris G wrote:
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.
If was being markup purist (apart from find the capital 'P' and the missing quote marks from the attribute value worrying) I would say that "bigmargin" is a bit of an odd class. Surely its more semantically pertinent to use values like "error" or "important"?
But, to answer the question, you can probably do something like this:
<div class="main-text"> <p> ... </p> <p> ... </p> </div>
with CSS: .main-text p {margin-top:15px;margin-bottom:15px}
This CSS rule selects all 'p's which are children of an element with the class "main-text".
I haven't checked it, though.
No you haven't have you! :-)
The above was *exactly* what I thought would work but it doesn't, as I explicitly pointed out margin settings are not inherited. Thus although other things set in class "main-text" will be set in those paragraphs the margins won't be. That was why I asked the question.
With your code above the <div> block gets the 15px margins and the paragraphs get their previous default.