Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Html Tags > Re: <h1>
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 373 of 439
Post > Topic >>

Re: <h1>

by Todd Brown <tbrown@[EMAIL PROTECTED] > Oct 20, 2005 at 01:49 AM

Wow, Frank, you got some crappy replies to your question (though I do 
agree with Jukka about Sledge's reply.)  Anyway, here's my take:

First of all, never, ever "forget" the </h1> tag.  While it's true that 
some browsers will "recoer" from this error, others won't.  In short, 
it'll render the way you want it on some browsers and not on others. 
While you're at it, never "forget" any close tags.  That goes for <img>,
<p> and everything else, too.  I might add here, that I tested your 
samples on Firefox 1.07 and IE6 and I couldn't reproduce the behavior 
you describe; like I said, browser behavior will vary drastically if you 
don't close your tags.

If I'm understanding your question correctly, you want to kill the space 
between an <h1> and <h2> tag.  Let's start with *why* there's space 
between the two.  Most modern browsers have a default style sheet which 
determines all of these characteristics.  Those default style sheets 
vary from browser to browser, but you can rest assured that there's 
margin/padding specified below the <h1> or before the <h2>.

You can *see* padding; just set a background color and you can see where 
the padding is.  You can't see margin, tho, but you can guess it's there 
based on where elements are placed.  So let's start with this:

<h1 style="background-color: blue;">h1 text</h1>
<h2 style="background-color: green;">h2 text</h2>

Chances are, you will see that the background tightly surrounds the text 
(and extends to the width of the window) and there's space between the 
blue and green boxes.  That space is caused by the margins.  Let's get 
rid of both the top and bottom margins:

<h1 style="background-color: blue; margin-bottom: 0;">h1 text</h1>
<h2 style="background-color: green; margin-top: 0;">h2 text</h1>

Now your elements should be butted up against one another.  Use an 
element selector in your stylesheet to set this property for *all* h1 & 
h2 elements.  Keep in mind that setting the margin is indiscriminate: 
you will find regular text is now closer to your headings, too.

Oh, and one last thing: I would strongly reccommend you to surround 
*all* text in some kind of block element, like <p> or <div>.  For example:

GOOD:
<body>
   <h1>Header Text</h1>
   <h2>Subheader Text</h2>
   <p>Blah blah blah</p>
</body>

BAD:
<body>
   <h1>Header Text</h1>
   <h2>Subheader Text</h2>
   Blah blah blah
</body>

Don't forget to use a validator to make sure you're not writing stupid 
code: http://validator.w3.org/

                 Cheers,
                   T


> Hi,
> I've got a little problem:
> If I "forget" the </h1>-tag, html produces just a line break.
> If I add the </h1> I get an empty line.
> How to avoid this?
> 
> Example:
> 
> Code 1:
> <h1>EXAMPLE<h2>More Text
> Output 1:
> EXAMPLE
> More Text
> 
> Code 2:
> <h1>EXAMPLE</h1><h2>More Text</h2>
> Output 2:
> EXAMPLE
> 
> More Text
> 
> Thanks for Your help!
> 
> Frank
> 
>




 6 Posts in Topic:

"Frank Ehrlacher&quo  2005-10-15 14:08:56 
Re:

"Jukka K. Korpela&qu  2005-10-15 16:10:23 
Re:

Sledge <Spam_Me@[EMAIL  2005-10-16 00:32:33 
Re:

"Jukka K. Korpela&qu  2005-10-16 20:32:49 
Re:

Skot Njordulf <necrowu  2005-12-05 06:05:25 
Re:

Todd Brown <tbrown@[EM  2005-10-20 01:49:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 1:33:30 CDT 2008.