Remove space between lines

I have a H2 subhead and a p paragraph. There is a blank line that seperates the two.

How do I remove this line?

Thanks,

Jon

Simple CSS reset will do the trick.

  • {margin:0;padding:0}

You then have a level playing field (nothing has margins or padding) and can then set the margin and padding as you desire.

That will have many undesirable side-effects, requiring Jon to specify margins and padding explicitly for every element type that needs them.

To solve the problem at hand:

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

This will remove the bottom margin from all H2 elements and the top margin from all paragraphs. If that’s undesirable, set a class on the heading:

<h2 class="subhead">

Then adapt the CSS rules:

h2.subhead {margin-bottom:0}
h2.subhead+p {margin-top:0}

The last rule won’t work in IE6 and older. If that’s necessary you’ll have to add a class on the paragraph as well.

Tommy is right, stripping margin/padding from form fields is ‘reason’ enough to stay away from that approach.

And the problem with that is? They have to be set anyway, unless you’re going to let the browser pick whatever they thinks best.

Yes, which is why I haven’t used that reset in ages… for people learning, its a good starting point.

If you set a ‘border’ to all inputs:

  1. borders are set to ‘checkboxes/radios’ in ie6.
    Then you have to go back and set a class to override those ‘borders’.

Here is a better article to explain this:

Did I miss something? Borders?

Excuse my ‘sleep-deprived’ mind :slight_smile:

The article, also should explain about ‘why’ not to zero out the margin/padding.

That’s right, and the browser defaults are perfectly appropriate in most instances. Only if you’re doing the sort of pixel-perfect print-design-wannabe layouts do you need exact control over every single margin and padding.

And if you’re going to set all margins and padding manually anyway, there’s not much point in first setting them to zero for every element. :wink:

You don’t get clients who love to tell you something is 1px off? Lucky you :smiley:

I use a simple reset the does the usual ul, p and so forth (it doesn’t including inputs or selects for the same reasons that article talks about). I find it ends up using less CSS (I add less margins/paddings than I would if I added margin:0;padding:0 to margins I don’t want margin or padding on) and I have more control, especially with particular clients.

Thanks