PDA

View Full Version : Can I get rid of the line gap that a <p> automatically gives?


Andromeda
05-25-2007, 03:40 AM
With the web site I am currently working on, I have my h2s in green and bold - and my paragraphs in blue as shown here:
http://www.wtl.org.nz/newmembership.html
(Sorry Chris - haven't come up with an acceptable alternative to the yellow header yet!!)

What I want to do is to keep those settings but have no line gap between the< h2> and the <p>. Is there anyway to style the <p> so that it doesn't give that line gap?

edbr
05-25-2007, 04:46 AM
why not do it all in <p> and make a span class for the headings

fwr1000
05-25-2007, 11:34 AM
Try setting the bottom margins for your H1 tag to 0 and the top margin for your p tag to 0. If that's "too close", set to a number that gives you the distance you desire.

domedia
05-25-2007, 01:30 PM
fwr's CSS code:

h2 {margin-bottom: 0;}
p {margin-top: 0;}

Andromeda
05-26-2007, 01:58 AM
Ed, thank you for your suggestion but I wanted to keep the <h2>s as <h2>s. It was my understanding that <h2>s had more weight than <p>s when it came to search engine optimisation although I could be mistaken.

fwr1000 and Domedia, thank you for your suggestion - it works perfectly. I had tried that but my mistake was setting the margin to the <p> and then undoing that and then setting the margin to the <h2>. I didn't try them together!!

edbr
05-28-2007, 03:09 AM
No you are correct. Also SE's are very happy about bold and italics, not sure where they all come in the pecking order though

chriskq
05-31-2007, 11:42 AM
Also SE's are very happy about bold and italics

im not so sure about that.
Definatly H1 and H2s are read on the page by spiders... up there just after the page title i think

domedia
05-31-2007, 02:18 PM
Maybe *very* happy is an exaggeration, but the so-called experts seems to agree that Google, for example, does take notice of words that are bold (strong) or italics (emphasized), so some advice to put important keywords on your page in <b><strong><i> or <em> in addition to <title><h1><h2> etc.

chriskq
05-31-2007, 11:38 PM
so your saying i should use inline styling on my page (and make it more bulky and code messy) instead of putting the appropriate element styling in my css?

can understand were your coming from dom.... just dont like it. lol

domedia
06-05-2007, 02:44 PM
so your saying i should use inline styling on my page (and make it more bulky and code messy) instead of putting the appropriate element styling in my css? Absolutely not :) Where did you get that from? h1, h2, em, i, strong, b, etc are tags, not inline styling.