CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2008
    Posts
    29

    Question Problem with div and h1 tag of HTML

    Hi!

    when h1 tag of HTML is nested inside div tag, in Netscape Navigator it leaves vertical space before h1 tag contents, which doesn't happen in IE. Why is it so?

    example:

    <div>
    <h1>Contents</h1>
    </div>

    Thank you.

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Problem with div and h1 tag of HTML

    [ moved ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: Problem with div and h1 tag of HTML

    Have you tried changing the margin and padding?

    Code:
    <div>
    <h1 style="margin: 0px; padding: 0px;">Contents</h1>
    </div>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Jul 2008
    Posts
    29

    Question Re: Problem with div and h1 tag of HTML

    Thanks for your reply. I tried it using "margin" property of CSS and it works fine in Netscape Navigator.

    Though the above solution works, I want to know why it happens in Netscape Navigator and in other browsers except IE. Where is the problem? If we do the same thing using "table" tag instead of "div" it works fine without using "margin".

    Thank you

  5. #5
    Join Date
    Aug 2005
    Location
    Imperial College London, England
    Posts
    490

    Re: Problem with div and h1 tag of HTML

    Because IE has different default to everyone else? Or, sometimes, thig come out differently if your code isn't quite correct all the way through (nesting mistake, etc. etc.)
    Help from me is always guaranteed!*
    VB.NET code is made up on the spot with VS2008 Professional with .NET 3.5. Everything else is just made up on the spot.
    Please Remember to rate posts, use code tags, send me money and all the other things listed in the "Before you post" posts.

    *Guarantee may not be honoured.

  6. #6
    Join Date
    Jul 2008
    Posts
    29

    Re: Problem with div and h1 tag of HTML

    According to W3C standards, there is no mistake in the code (nesting of HTML elements).

  7. #7
    Join Date
    May 2002
    Posts
    10,943

    Re: Problem with div and h1 tag of HTML

    It's not a mistake in the code, it's simply differences in web browsers. Any professional web developer/designer will tell you that the #1 problem in this industry is cross browser solutions.

    Personally, I won't ever touch Netscape. It has declared its own end-of-life and therefore isn't worth the hassle. As long as what you write appears fine in IE, Firefox, and Safari for PC, as well as in Safari and Firefox for Mac, you will be okay! Those make up over 99% of the commonly used browsers.

    Also, remember to always declare your doctype. This tends to be the distinguishing role in how cross browser implementation changes minimally. As long as the doctype is declared, you should need to make less revisions to your code for each specific browser.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  8. #8
    Join Date
    Jul 2008
    Posts
    29

    Smile Re: Problem with div and h1 tag of HTML

    Thanks for your reply. it cleared my doubt.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured