Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I eliminate spacing after h1 or h2 tags?

Status
Not open for further replies.

okpeery

Instructor
Dec 29, 2005
102
US
I want my <p> to start right below my h1 and h2 tags. Does it make more sense to not use h1 or h2 tags and just use a larger font or should I just eliminate the space? I know I saw how to do it somewhere but I forgot where. It is for a resume. Under Education I want my universities listed right underneath the heading.
 
[ol][li]Can you give us a link to (or show us the sourcecode from) your page so we can see what you're working with here?[/li]
[li]Why are you using the [tt]<p>[/tt] tag? That's most likely what's causing your undesired space.[/li][/ol]


Hope this helped;
Rob Hercules
 
Try this:
Code:
<h2 style="margin-bottom:0;">My Title</h2>
If you want it to behave that way all the time, put this in the head of your document or a separate CSS file:
Code:
<style type="text/css">
h2 {margin-bottom: 0;}
</style>
Or you can make a class so that you can selectively apply it:
Code:
<style type="text/css">
.nobottom {margin-bottom: 0;}
</style>
...later...
<h2 class="nobottom">My Title</h2>

I hope that helps. It sounds like you're new to CSS, but if I've misjudged you and you are actually asking something more difficult, pardon me for teaching basics.
 
OsakaWebbie is correct. If you experience too much of a gap still, just control the margins on paragraph tag as well. Use semantic markup like you do, h* tags for titles and p tags for text and use css to make them behave the way you want to.
 
I thought it was more of a simple fix. I will post my code later, I am at the wrong computer right now. Thanks for the replies so far.
 
My suggestion isn't simple? Sorry if I confused you with too many choices, but you only need one of them. Just try this:
Code:
<h2 style="margin-bottom:0;">Education</h2>
<p style="margin-top:0;">Harvard University...</p>
It's not hard to make the tags behave the way you want, once you know the commands. Sit! Stay! Roll over!... :)
 
I digress...just tested w/o the <p> tag & it wasn't the major issue here. The following code worked in my test page w/no extra spacing following the [tt]<h2>[/tt] though:
Code:
<html><head></head><body>
<h2 style="margin-bottom:0;">Hello</h2>
Good-Bye
</body></html>

I've gotta give it to OsakaWebbie on this one, I've been bested. :)




I hope this helps;
Rob Hercules
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top