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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Don't have complete control over <h2> with CSS 2

Status
Not open for further replies.

makemusic

Programmer
Apr 3, 2004
43
I'm using CSS to control the features of my <h2> tag, but some of the default settings associated with <h2> are over-riding my CSS. It seems that CSS will not completely control the size of my headings because I'm still getting that big space underneath the heading.

Can I not completely control my tags to make them look like normal body text?
 
Don't forget to manually set the margins and padding.

Code:
h2 {
    font-face: 'Trebuchet MS', sans-serif;
    font-size: 24px;
    [i]margin: 0;
    padding: 0;[/i]
    color: blue;
}

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
Sorry, that should be [tt]font-family[/tt], not [tt]font-face[/tt]. Don't know where that came from.

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
You can do that, I don't really know why, but you can. <h*> tags have by default margins at the top and bottom. If you nulify that, they should appear more like every other text. They are also block level elements, meaning that they start in a new line. If you would like to cancel that, consider display: inline; For cross-browser reasons, you might also want to apply padding to them to cancel default padding.
Code:
h2 {
  padding: 0;
  margin: 0;
  font-size: 1em;
}

or 

h2 {
  font-size: 1em;
  display: inline; /* this will cancel margins */
}
 
no prob. thanks to vrag too :)

*cLFlaVA
----------------------------
[tt]Sigs cause cancer.[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top