Forum Moderators: not2easy
Header tags.
I never thought that they would have been so much bother. Basicaly, I want H1 to represent bold writing, and H2 to represent bold, italic writing.
My font is Verdana and 8px and I want my headers to be the same, except with weight and style applied.
However rather than appearing like this:
Header:
The quick brown fox jumped over the lazy dog.Sub-Header:
The quick brown fox jumped over the lazy dog.
They're like this:
Header:The quick brown fox jumped over the lazy dog.
Sub-Header:
The quick brown fox jumped over the lazy dog.
Why are there such big spaces?
<h1>Heading:</h1>
<p>The quick brown fox jumped over the lazy dog.</p><h2>Sub-Heading:</h2>
<p>The quick brown fox jumped over the lazy dog.</p>
you can use CSS to remove the margin in several different ways, for instance
/* text style rules */
h1, h2, p {font: 8px Verdana, sans-serif;}
h2 {font-style: italic;}/* spacing rules */
h1, h2 {margin-bottom: 0;}
p {margin-top: 0;}
This removes the gap between the heading and the first paragraph, but retains a line break between paragraphs (caused by the default bottom margin of <p>).
Now, in Firefox and other standards-compliant browsers, you could be much more specific and say
h1+p, h2+p {margin-top: 0;} i.e. only zero out the top margin of paragraphs which immediately follow an <h1> or <h2>. But Internet Explorer does not recognize this syntax ("adjacent sibling selectors" in the parlance).
If you run into problems adjust the line-height code until it works, between 0 and 8
AltherrWeb, welcome to WebmasterWorld! You can compact your code by using CSS shorthand notation; also, setting line-height to zero will almost certainly yield unintended consequences.
h2 {
font-family: verdana, arial, sans-serif;
font-size: 8pt;
font-style: italic;
font-weight: bold;
line-height: 8pt;
}h1 {
font-family: verdana, arial, sans-serif;
font-size: 8pt;
font-style: normal;
font-weight: bold;
line-height: 0pt;
}
I did what you said, however, when I have my page like this.
Header 1
<p>
Header 2
text and lots of it.
<p>
Header 2
Image to compliment
It appears okay, however, the header 2 at the top, appears really close to the bottom of header 1.