Forum Moderators: not2easy

Message Too Old, No Replies

suggestion please, css <p> properties

is it possible to have more then one <p>properties

         

abenzio

8:39 am on Aug 6, 2008 (gmt 0)

10+ Year Member



hi i am new to css, i would like to know if we can define the paragraph properties more then one
for example
p {padding: 15px; border: 3px solid black; } and
p.double {border-style: double; }

please advice me.
thanks

D_Blackwell

2:19 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Absolutely. In the example provided:

The first declaration states that ALL <p> will be rendered as described.

The second declaration states that <p class="double"> will override all <p> on border-style: and have a double border.

The risk here is the usage of the 'global' <p>. It will be used on every paragraph on the page if embedded in the head, or every paragraph on the website if linked as an external stylesheet.

Unless you are absolutely sure that you won't want some other padding or border down the road, this could cause a lot of hassle as the site gets bigger.

If you are worried about "Well, almost all of my <p> are like this.", then you still have some options. For example, in a large text section with numerous <p> you can specify something like the following:

.lots-o-text p {
padding: 15px; border: 3px solid black;
}

In this case, use <div class="lots-o-text"> as a wrapper, and every <p> within that <div> class, and only that <div> class, will use that <p> declaration.

abenzio

7:37 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



thanks a lots D_Blackwell.